Events and Callbacks
From OpenAlchemy.org
Pwrap has events and callbacks which are driven by eventloops. So the application will be in sleep state unless an event occurs. Eventloops are not Unixsystem signals, but the UI signals which every widget inherit in X-windows, like the exit signal on press of the exit button.
Controls are passed using these signals. For example, on release of a button, a signal handler catches the signal and passes it to a function called by the callback event. In the callback function, we define the appropriate action to be performed. The callback function for an event can be set in the pwrap world using:
void pw_set_callback(pw_widget widget, unsigned eventtype, Bool (*callback)(px_widget*, px_event*));
The eventtype that appear in the above API can be any of the following:
- PW_BUTTON_PRESS_EVENT
- PW_BUTTON_RELEASE_EVENT
- PW_MOTION_EVENT
- PW_MOUSE_ENTER_EVENT
- PW_MOUSE_LEAVE_EVENT
- PW_KEY_PRESS_EVENT
- PW_KEY_RELEASE_EVENT
- PW_CONFIGURE_EVENT
- PW_CLIENT_MESSAGE_EVENT
- PW_VISIBILITY_EVENT
- PW_WINDOW_DELETE_EVENT
The first two events PW_BUTTON_PRESS_EVENT and PW_BUTTON_RELEASE_EVENT</code> are the standard button press and button release events whichcan be set for buttons, radiobuttons and checkbuttons.
The events PW_MOTION_EVENT, PW_MOUSE_ENTER_EVENT, PW_MOUSE_LEAVE_EVENT, PW_KEY_PRESS_EVENT, PW_KEY_RELEASE_EVENT, PW_CONFIGURE_EVENT, PW_CLIENT_MESSAGE_EVENT, PW_VISIBILITY_EVENT and PW_WINDOW_DELETE_EVENT can be applied to any widget.
But the events PW_CONFIGURE_EVENT, PW_CLIENT_MESSAGE_EVENT and PW_WINDOW_DELETE_EVENT are generally used for toplevel window as they have to bind many Alchemy APIs such as keyboard, email and uparrow, etc.
void pw_set_callback_parameter(pw_widget_widget, unsigned eventtype, void *parameter);
It can be used to send a parameter to the callback function which is set by the pw set callback. In the callback function, the parameter can be accessedusing pw_event_callback_parameter function.
