Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable mouse wheel scrolling in GtkOptionMenu/GtkComboBox

Does anyone know how to disable mouse scrolling in a GtkOptionMenu or GtkComboBox? It is annoying when you are scrolling through a window and the pointer passed over such a widget which grabs the focus and changes value!

I see that the offending code was added a while back, but there doesn't seem to be any mechanism in place to disable this functionality.

I am working in C, but help in any language would be much appreciated.

P.S. I should maybe mention that I'm using GTK 2.10, but need compatibility with GTK 2.4.

like image 241
Scott Milne Avatar asked Oct 27 '25 22:10

Scott Milne


1 Answers

This works - I hope might help someone else that wants to do the same thing:

/* Create new closure (callback) to replace class default */   
GClosure * new_closure = 
  g_cclosure_new_object( G_CALLBACK(handler), /* my event handler */
                         G_OBJECT(gobject) /* use any static GObject to keep closure alive */
                       );

GType type = gtk_option_menu_get_type();

/* Get signal_id for "scroll_event" */
guint signal_id = g_signal_lookup("scroll_event", type);

/* Override default closure for scroll_event signal */
g_signal_override_class_closure(signal_id, type, new_closure);
like image 157
Scott Milne Avatar answered Oct 30 '25 13:10

Scott Milne