Skip to content

Instantly share code, notes, and snippets.

@angstyloop
Created October 10, 2023 22:00
Show Gist options
  • Save angstyloop/d7e6cdd5c813cd0304274ec5ad289b8f to your computer and use it in GitHub Desktop.
Save angstyloop/d7e6cdd5c813cd0304274ec5ad289b8f to your computer and use it in GitHub Desktop.
Disable "scroll" event propagation on a widget that receives the "scroll" event in GTK4.
/* Disable scroll on a widget by adding a capture phase event handler and
* connecting a no-op callback to the "scroll" event.
*/
static GtkWidget *
disable_scroll( GtkWidget *w )
{
GtkEventController *ec;
ec = gtk_event_controller_scroll_new(
GTK_EVENT_CONTROLLER_SCROLL_VERTICAL );
gtk_event_controller_set_propagation_phase( ec, GTK_PHASE_CAPTURE );
g_signal_connect( ec, "scroll", G_CALLBACK( disable_scroll_cb ), w );
gtk_widget_add_controller( w, ec );
return w;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment