I have (in GTK 2.2, Ubuntu 10.04) a drawing-area widget that needs to react to a number of events, amongst which the mouse wheel. I had expected the latter to cause button-4 & 5 presses and releases, to be delivered in the same way as the other button events (which work like a charm). But no such events arrive, when I operate the mouse wheel.
So I added GDK_SCROLL_MASK to the widget with add_event, and g_signal_connect "scroll-event", just like I added the button presses. But still, no joy. The mouse wheel is completely ignored. In the Xaw version of the code, from which this was ported, I do get the button 4 & 5 events, so I know the hardware is working.
Is there anything else I would have to do to attach a callback to the mouse wheel?
Code:
g_signal_connect (graph, "expose-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
gtk_widget_add_events(GTK_WIDGET(graph), GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK );
g_signal_connect (graph, "button-press-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
g_signal_connect (graph, "button-release-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
g_signal_connect (graph, "scroll-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);
g_signal_connect (graph, "motion-notify-event", G_CALLBACK (GraphEventProc), (gpointer) &option[i]);