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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]