Next: , Previous: , Up: Part III Button-like Objects   [Contents][Index]


16.3 Button Interaction

FL_NORMAL_BUTTONs, FL_PUSH_BUTTONs, FL_RADIO_BUTTONs, FL_RETURN_BUTTONs and FL_HIDDEN_BUTTONs are returned at the moment the user releases the mouse after having pressed it on the button. A FL_MENU_BUTTON, in contrast, is returned already on a mouse press. A FL_INOUT_BUTTON is returned both when the user presses it and when the user releases it. A FL_TOUCH_BUTTON is returned all the time as long as the user keeps the mouse button pressed while the mouse is on top of it. A FL_RETURN_BUTTON and a FL_HIDDEN_RET_BUTTON are also returned when the user presses the <Return> key.

As for other “active” objects, you can control under which conditions a button object gets returned or its callback invoked by using the function

int fl_set_object_return(FL_OBJECT *obj, unsigned int when);

where reasonable values for when are

FL_RETURN_NONE

Never return object or invoke callback.

FL_RETURN_END_CHANGED

Return object or invoke callback when mouse button is released and at the same moment the state of the button changed.

FL_RETURN_CHANGED

Return object or invoke callback whenever the state of the button changes.

FL_RETURN_END

Return object or invoke callback when mouse button is released

FL_RETURN_ALWAYS

Return object or invoke callback on all of the above condtions.

Most buttons will always return FL_RETURN_END and FL_RETURN_CHANGED at the same time. Exceptions are FL_INOUT_BUTTONs and FL_TOUCH_BUTTONs. The former returns FL_RETURN_CHANGED when pushed and both FL_RETURN_END and FL_RETURN_CHANGED together when released. FL_TOUCH_BUTTONs return when pressed, then FL_RETURN_CHANGED at regular time intervals while being pressed and finally FL_RETURN_END when released.

See demo butttypes.c for a feel of the different button types.


Next: , Previous: , Up: Part III Button-like Objects   [Contents][Index]