From de32ffe92c1ff1f93a2b8e0cdb777dc1114dc751 Mon Sep 17 00:00:00 2001 From: Urtsi Santsi Date: Thu, 16 Jan 2025 08:42:35 +0200 Subject: [PATCH] Fixes #222 - left click on a button leaves "Left" button with "suggested-action" style The reason that happens is that when clicking on a button, the button claims the "released" gesture and we don't get the "released" signal. Setting the propagation fhase to "CAPTURE" allows us to handle the event before the button claims it. --- src/Event Controllers/main.js | 1 + src/Event Controllers/main.py | 1 + src/Event Controllers/main.vala | 1 + 3 files changed, 3 insertions(+) diff --git a/src/Event Controllers/main.js b/src/Event Controllers/main.js index 1f5c4a9c..b7fbe96b 100644 --- a/src/Event Controllers/main.js +++ b/src/Event Controllers/main.js @@ -44,6 +44,7 @@ ctrl_button.connect("clicked", () => { // Detect pointer button press and release events const gesture_click = new Gtk.GestureClick({ button: 0 }); +gesture_click.propagation_phase = Gtk.PropagationPhase.CAPTURE; window.add_controller(gesture_click); diff --git a/src/Event Controllers/main.py b/src/Event Controllers/main.py index a614bd50..5de016e8 100644 --- a/src/Event Controllers/main.py +++ b/src/Event Controllers/main.py @@ -84,6 +84,7 @@ def on_swipe(_self, vel_x, _vel_y): # Detect pointer button press and release events gesture_click = Gtk.GestureClick(button=0) +gesture_click.set_propagation_phase(Gtk.PropagationPhase.CAPTURE) window.add_controller(gesture_click) gesture_click.connect("pressed", on_pressed) gesture_click.connect("released", on_released) diff --git a/src/Event Controllers/main.vala b/src/Event Controllers/main.vala index 0423a122..febaa3f8 100644 --- a/src/Event Controllers/main.vala +++ b/src/Event Controllers/main.vala @@ -47,6 +47,7 @@ public void main () { var gesture_click = new Gtk.GestureClick () { button = 0 }; + gesture_click.propagation_phase = Gtk.PropagationPhase.CAPTURE; ((Gtk.Widget) window).add_controller (gesture_click); gesture_click.pressed.connect ((gesture, n_press, x, y) => {