BUTTON_CB

IUP - Portable User Interface

BUTTON_CB

Action generated when a mouse button is pressed or released.

Callback

int function(Ihandle* ih, int button, int pressed, int x, int y, char* status); [in C]
elem:button_cb(but, pressed, x, y: number, status: string) -> (ret: number) [in Lua]

ih: identifies the element that activated the event.
button: identifies the activated mouse button:

IUP_BUTTON1 - left mouse button (button 1);
IUP_BUTTON2 - middle mouse button (button 2);
IUP_BUTTON3 - right mouse button (button 3).

pressed: boolean that indicates the state of the button:

0 - mouse button was released;
1 - mouse button was pressed.

x, y: position in the canvas where the event has occurred, in pixels.
status: status of the mouse buttons and some keyboard keys at the moment the event is generated. The following macros must be used for verification:

isshift(status)
iscontrol(status)
isbutton1(status)
isbutton2(status)
isbutton3(status)
isdouble(status)

They return 1 if the respective key or button is pressed, and 0 otherwise. These macros are also available in Lua.

Return: IUP_CLOSE will be processed.

Notes

This callback can be used to customize a button behavior. For a standard button behavior use the ACTION callback of the IupButton.

Affects

IupCanvas, IupButton, IupGLCanvas