Created
October 10, 2023 22:00
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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