Gtk4 GestureSwipe not properly detected on a Grid of Buttons

In my application I have a Notebook with 5 NotebookPages, each NotebookPage contains an array of 4 x 5 Buttons. I can of course switch the NotebookPages by clicking on the corresponding tab.

What I want, however, is to be able to swipe on the Grid of Buttons to the left or right to change the Notebook Page.

When I add a GestureSwipe controller to the Notebook, it barely ever detects the swipe, and when it does, all the velocities are 0.

I think that here the detection of the Button press and the GestureSwipe detection interfere. Is there a way to a GestureSwipe controller over a Grid of Buttons?

Hi,

I think you need to catch the swipe event before it reaches the buttons by setting your GestureSwipe propagation phase to CAPTURE, see Gtk.EventController:propagation-phase
(by default the buttons will catch it first, in BUBBLE mode)

More infos on events propagation: Gtk – 4.0: Overview of GTK input and event handling

Thank you for the hint. Setting the propagation phase to capture indeed did the trick.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.