event
In addition to the signal mechanism described above, there is a set of Events reflect the X event mechanism. The callback function can be connected to these events. These events are:
eventbutton_press_eventbutton_release_eventscroll_eventmotion_notify_eventdelete_eventdestroy_eventexpose_eventkey_press_eventkey_release_evententer_notify_eventleave_notify_eventconfigure_eventfocus_in_eventfocus_out_eventmap_eventunmap_eventproperty_notify_eventselection_clear_eventselection_request_eventselection_notify_eventproximity_in_eventproximity_out_eventvisibility_notify_eventclient_eventno_expose_eventwindow_state_event connection function g_signal_connect () callback functions and events, as before, with the event name as the name of the parameter. The callback function of the event is different from the callback function of the signal:
Gint Callback_func (gtkwidget * widget, gdkevent * Event, gpointer calback_data);
GDKEVENT is a C-shaped structure, which is dependent on which event in the above event occurs. In order to let us know which event has occurred, you can use a type member to reflect this event. Other parts of the event structure will depend on the type of this event. The possible values of the type are:
GDK_NOTHING GDK_DELETE GDK_DESTROY GDK_EXPOSE GDK_MOTION_NOTIFY GDK_BUTTON_PRESS GDK_2BUTTON_PRESS GDK_3BUTTON_PRESS GDK_BUTTON_RELEASE GDK_KEY_PRESS GDK_KEY_RELEASE GDK_ENTER_NOTIFY GDK_LEAVE_NOTIFY GDK_FOCUS_CHANGE GDK_CONFIGURE GDK_MAP GDK_UNMAP GDK_PROPERTY_NOTIFY GDK_SELECTION_CLEAR GDK_SELECTION_REQUEST GDK_SELECTION_NOTIFY GDK_PROXIMITY_IN GDK_PROXIMITY_OUT GDK_DRAG_ENTER GDK_DRAG_LEAVE GDK_DRAG_MOTION GDK_DRAG_STATUS GDK_DROP_START GDK_DROP_FINISHED GDK_CLIENT_EVENT GDK_VISIBILITY_NOTIFY GDK_NO_EXPOSE GDK_SCROLL GDK_WINDOW_STATE GDK_SETTING
So, connect the event with a callback function, we will use this:
g_signal_connect (g_object (button), "Button_Press_Event", G_Callback (Button_Press_Callback), NULL;
Here, it is assumed that button is a button component. Now, when the mouse is placed on the button and press the mouse, the function button_press_callback () will be called. This function should be declared as:
Static Gint Button_Press_Callback (gtkwidget * Widget, GdkeventButton * Event, GPOINTER DATA); Note that we can declare the second parameter type as GDKEventButton because we know which type of event will happen.
The return value of this function indicates whether this event should be further propagated by the GTK event handler. Returns TRUE Indicates that this event has been processed and should not be further propagated. Returns False to continue normal event processing. See the high-level events and signal processing for details.
GDKEVENT Data Type Details Please refer to Appendix GRK Event Type.
GDK selection and drag and drop APIs also issued a number of events to reflect in GTK. These two chapters of the signals and signals on the source components of the contents of the following signals:
SELECTION_RECEIVEDSELECTION_GETDRAG_BEGIN_EVENTDRAG_END_EVENTDRAG_DATA_DELETEDRAG_MOTIONDRAG_DROPDRAG_DATA_GETDRAG_DATA_RECEIVED