I’m tracking the mouse movement in a GtkDrawingArea
.
I have set up the callbacks for movement, enter and leave (which all work).
I’m using the same callback for all three event types, examining the event returned to differentiate them.
I get the expected EventType
(GDK_MOTION_NOTIFY
) for movement but I get 0
for enter and leave (rather than 6 & 7 - GDK_ENTER_NOTIFY
& GDK_LEAVE_NOTIFY
). What am I missing?
Michael
void on_PlotMouseMotion (
GtkEventControllerMotion* self, gdouble x, gdouble y, gpointer wDrawingArea
) {
GdkEventType eventType = gdk_event_get_event_type( gtk_event_controller_get_current_event( GTK_EVENT_CONTROLLER( self ) ) );
g_print( "%d - x: %.1lf y: %.1lf\n", eventType, x, y );
}
GtkEventController *eventMouseMotion = gtk_event_controller_motion_new ();
gtk_event_controller_set_propagation_phase(eventMouseMotion, GTK_PHASE_CAPTURE);
g_signal_connect(eventMouseMotion, "motion", G_CALLBACK( on_PlotMouseMotion ), wDrawingArea);
g_signal_connect(eventMouseMotion, "enter", G_CALLBACK( on_PlotMouseMotion ), wDrawingArea);
g_signal_connect(eventMouseMotion, "leave", G_CALLBACK( on_PlotMouseMotion ), wDrawingArea);
gtk_widget_add_controller (wDrawingArea, GTK_EVENT_CONTROLLER (eventMouseMotion));