[gtk/search-entry-capture: 2/2] searchbar: Capture events in the bubble phase




commit 8a0d4dfa941faba793d98c58babf0d7e151b4a88
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 25 22:16:29 2021 -0500

    searchbar: Capture events in the bubble phase
    
    This is an unfortunate naming clash, but it avoids
    an event handling clash between the capture widget
    and its children.
    
    Fixes: #3098

 gtk/gtksearchbar.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c
index 23c5fa5492..0ecc2952c1 100644
--- a/gtk/gtksearchbar.c
+++ b/gtk/gtksearchbar.c
@@ -590,11 +590,19 @@ capture_widget_key_handled (GtkEventControllerKey *controller,
  * @bar: a #GtkSearchBar
  * @widget: (nullable) (transfer none): a #GtkWidget
  *
- * Sets @widget as the widget that @bar will capture key events from.
+ * Sets @widget as the widget that @bar will capture key events
+ * from.
  *
  * If key events are handled by the search bar, the bar will
  * be shown, and the entry populated with the entered text.
- **/
+ *
+ * Note that despite the name of this function, the events
+ * are only 'captured' in the bubble phase, which means that
+ * editable child widgets of @widget will receive text input
+ * before it gets captured. If that is not desired, you can
+ * capture and forward the events yourself with
+ * gtk_event_controller_key_forward().
+ */
 void
 gtk_search_bar_set_key_capture_widget (GtkSearchBar *bar,
                                        GtkWidget    *widget)
@@ -622,7 +630,7 @@ gtk_search_bar_set_key_capture_widget (GtkSearchBar *bar,
 
       bar->capture_widget_controller = gtk_event_controller_key_new ();
       gtk_event_controller_set_propagation_phase (bar->capture_widget_controller,
-                                                  GTK_PHASE_CAPTURE);
+                                                  GTK_PHASE_BUBBLE);
       g_signal_connect (bar->capture_widget_controller, "key-pressed",
                         G_CALLBACK (capture_widget_key_handled), bar);
       g_signal_connect (bar->capture_widget_controller, "key-released",


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