Event @ GTK + 2.0 Chinese tutorial serialization

Source: Internet
Author: User
Tags gtk
Event

In addition to the signal mechanism described above, there is also a setEvents
Reflects x event mechanisms. Callback functions can be connected to these events. These events are:

  • Event
  • Button_press_event
  • Button_release_event
  • Scroll_event
  • Motion_policy_event
  • Delete_event
  • Destroy_event
  • Expose_event
  • Key_press_event
  • Key_release_event
  • Enter_policy_event
  • Leave_policy_event
  • Configure_event
  • Focus_in_event
  • Focus_out_event
  • Map_event
  • Unmap_event
  • Property_policy_event
  • Selection_clear_event
  • Selection_request_event
  • Selection_policy_event
  • Proximity_in_event
  • Proximity_out_event
  • Visibility_policy_event
  • Client_event
  • No_expose_event
  • Window_state_event

To connect a callback function to one of these events, you use the g_signal_connect () function, as described earlier, using one of the above event namesName
Parameters. The Event Callback Function is slightly different from the signal callback function:

gint callback_func( GtkWidget *widget,
GdkEvent *event,
gpointer callback_data );

Gdkevent is a CUnion
Structure. Its type depends on the event in the preceding event. Each possible type hasType
Members. The rest of the event structure depends on the event type. Possible values of the type include:

  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

Therefore, to connect a callback function to one of these events, we will use:

g_signal_connect (G_OBJECT (button), "button_press_event",
G_CALLBACK (button_press_callback), NULL);

It is assumed thatButton
Is a button component. The button_press_callback () function is called when the mouse is placed on the button and clicked. This function should be declared:

static gint button_press_callback( GtkWidget      *widget, 
GdkEventButton *event,
gpointer data );

Note that we can declare the second parameter typeGdkeventbutton
Because we know which type of event will happen.

The return value of this function indicates whether the event should be further transmitted by the GTK event processor. Returns true to indicate that the event has been processed and should not be further propagated. Returns false to continue normal event processing. For details, see
Advanced event and signal processing
This chapter.

For details about gdkevent data types, see Appendix gdk event types
.

The gdk selection area and drag-and-drop interface functions also issue many events, which are reflected by signals in GTK. For details about the following signals, see the signals on the source component.
And signal on the target component
These two chapters:

  • Selection_received
  • Selection_get
  • Drag_begin_event
  • Drag_end_event
  • Drag_data_delete
  • Drag_motion
  • Drag_drop
  • Drag_data_get
  • Drag_data_received
<Previous Home Next >>>
Principles of signal and callback Functions Up Hello World

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.