Re: disabling mouse scroll on GtkComboBox and spin buttons
I sent a post about this in January. My solution retains the scrolling feature but disables it when scrolling the parent window. Note that each combobox is inside an event box and hence the gtk_bin_get_child in combobox_scroll_fix. static gboolean _block_scroll = TRUE; static void combobox_no_scroll(GtkWidget *combo, gpointer data){ if(_block_scroll) g_signal_stop_emission_by_name(combo, "scroll-event"); } static void combobox_focus_in(GtkWidget *combo, gpointer data){ _block_scroll = TRUE; } static void combobox_motion_notify(GtkWidget *combo, gpointer data){ _block_scroll = FALSE; } static void combobox_scroll_fix(GtkWidget *w){ g_signal_connect(w, "enter-notify-event", G_CALLBACK(combobox_focus_in), NULL); g_signal_connect(w, "motion-notify-event", G_CALLBACK(combobox_motion_notify), NULL); g_signal_connect(gtk_bin_get_child(GTK_BIN(w)), "scroll-event", G_CALLBACK(combobox_no_scroll), NULL); } On Sun, 2016-05-22 at 23:38 +0530, Lokesh Chakka wrote: > thanks guys > > I am using like this: > > g_signal_connect( spin_button, "scroll-event", G_CALLBACK(gtk_true), NULL ); > g_signal_connect( combo_box, "scroll-event", G_CALLBACK(gtk_true), NULL ); > > issue resolved.. > > Thanks & Regards > -- > Lokesh Chakka, > Mobile: 9731023458 > > On Sun, May 22, 2016 at 8:48 PM, Ben Iofelwrote: > > > There's a utility function for just returning true: gtk_true > > > > On Sun, May 22, 2016, 6:53 AM wrote: > > > > > On 22 May 2016 at 10:57, Florian Pelz > > wrote: > > > > On 05/22/2016 11:54 AM, jcup...@gmail.com wrote: > > > >> x = gtk_combo_box_new_text(); > > > >> g_signal_connect(x, "scroll-event", G_CALLBACK(true_cb), NULL); > > > >> ... > > > > > > > > Ah yes, this is a much better way. > > > > > > I'm not sure it'd work for spin buttons though :-( > > > > > > Something like your event masks, Florian, would probably be necessary for > > > that. > > > > > > John > > > ___ > > > gtk-app-devel-list mailing list > > > gtk-app-devel-list@gnome.org > > > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > > ___ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: disabling mouse scroll on GtkComboBox and spin buttons
thanks guys I am using like this: g_signal_connect( spin_button, "scroll-event", G_CALLBACK(gtk_true), NULL ); g_signal_connect( combo_box, "scroll-event", G_CALLBACK(gtk_true), NULL ); issue resolved.. Thanks & Regards -- Lokesh Chakka, Mobile: 9731023458 On Sun, May 22, 2016 at 8:48 PM, Ben Iofelwrote: > There's a utility function for just returning true: gtk_true > > On Sun, May 22, 2016, 6:53 AM wrote: > > > On 22 May 2016 at 10:57, Florian Pelz > wrote: > > > On 05/22/2016 11:54 AM, jcup...@gmail.com wrote: > > >> x = gtk_combo_box_new_text(); > > >> g_signal_connect(x, "scroll-event", G_CALLBACK(true_cb), NULL); > > >> ... > > > > > > Ah yes, this is a much better way. > > > > I'm not sure it'd work for spin buttons though :-( > > > > Something like your event masks, Florian, would probably be necessary for > > that. > > > > John > > ___ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: disabling mouse scroll on GtkComboBox and spin buttons
There's a utility function for just returning true: gtk_true On Sun, May 22, 2016, 6:53 AMwrote: > On 22 May 2016 at 10:57, Florian Pelz wrote: > > On 05/22/2016 11:54 AM, jcup...@gmail.com wrote: > >> x = gtk_combo_box_new_text(); > >> g_signal_connect(x, "scroll-event", G_CALLBACK(true_cb), NULL); > >> ... > > > > Ah yes, this is a much better way. > > I'm not sure it'd work for spin buttons though :-( > > Something like your event masks, Florian, would probably be necessary for > that. > > John > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: disabling mouse scroll on GtkComboBox and spin buttons
On 22 May 2016 at 10:57, Florian Pelzwrote: > On 05/22/2016 11:54 AM, jcup...@gmail.com wrote: >> x = gtk_combo_box_new_text(); >> g_signal_connect(x, "scroll-event", G_CALLBACK(true_cb), NULL); >> ... > > Ah yes, this is a much better way. I'm not sure it'd work for spin buttons though :-( Something like your event masks, Florian, would probably be necessary for that. John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: disabling mouse scroll on GtkComboBox and spin buttons
On 05/22/2016 11:54 AM, jcup...@gmail.com wrote: > x = gtk_combo_box_new_text(); > g_signal_connect(x, "scroll-event", G_CALLBACK(true_cb), NULL); > ... Ah yes, this is a much better way. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: disabling mouse scroll on GtkComboBox and spin buttons
On 22 May 2016 at 07:36, Lokesh Chakkawrote: > Is there a way to disable mouse scroll on GtkComboBox and GtkSpinButton > widgets ? Yes, the mouse wheel to change the combo drives me CRAZY. It means you can't use the mouse wheel to scroll a window that contains widgets, since you might scroll a combo under the pointer accidentally, and then you start changing the combo value instead of scrolling. And once you've changed it, you can't change it back, because you've no idea what it was set to before. I block this in my code by connecting to scroll-event on the combo, for example: x = gtk_combo_box_new_text(); g_signal_connect(x, "scroll-event", G_CALLBACK(true_cb), NULL); ... where static gboolean true_cb(GtkWidget *wid, GdkEvent *event, void *data) { /* Stop any other scroll handlers running. We don't want the scroll * wheel to accidentally change widgets while we're moving. */ return TRUE; } John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: disabling mouse scroll on GtkComboBox and spin buttons
On 05/22/2016 08:36 AM, Lokesh Chakka wrote: > Hello, > > Is there a way to disable mouse scroll on GtkComboBox and GtkSpinButton > widgets ? > > an example will help much. > > Thanks & Regards > Use a function like static void disable_scroll (GtkWidget *widget) { GdkEventMask events; events = gtk_widget_get_events (widget); events &= ~0 ^ GDK_SCROLL_MASK; gtk_widget_set_events (widget, events); if (GTK_IS_CONTAINER (widget)) gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) disable_scroll, NULL); } and then after creating the GtkComboBox call gtk_container_forall (GTK_CONTAINER (combo), (GtkCallback) disable_scroll, NULL); It seems to work for me on a GtkComboBox called combo, but I'm not sure if it will survive on future GTK+ versions. Regards, Florian ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
disabling mouse scroll on GtkComboBox and spin buttons
Hello, Is there a way to disable mouse scroll on GtkComboBox and GtkSpinButton widgets ? an example will help much. Thanks & Regards -- Lokesh Chakka, Mobile: 9731023458 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list