BUTTON_CB

IUP - Portable User Interface

BUTTON_CB

Action generated when a mouse button is pressed or released.

Callback

int function(Ihandle* ih,int but,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 canvas that activated the function's execution.
but: 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: 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.

Notes

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

Affects

IupCanvas, IupButton, IupGLCanvas