Propagation of key press events
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list gnome org
- Subject: Propagation of key press events
- Date: 15 Nov 2001 15:07:37 -0500
As discussed earlier, here is a patch to propagate key press events up
the heirarchy ... it's trivial except for some refcounting/reentrancy
complications.
I tried using it to implement Ctrl-PageUp/Ctrl-PageDown in the
notebook, and that worked fine.
I'm going to commit this tomorrow morning unless I hear strong
objections and a good, equally simple, alternative suggestion about
how to do keypress bindings on parent widgets.
Regards,
Owen
Index: gtk/gtkwindow.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtkwindow.c,v
retrieving revision 1.164
diff -u -p -r1.164 gtkwindow.c
--- gtk/gtkwindow.c 2001/11/13 18:52:25 1.164
+++ gtk/gtkwindow.c 2001/11/15 19:58:57
@@ -3485,6 +3485,7 @@ gtk_window_key_press_event (GtkWidget
GdkEventKey *event)
{
GtkWindow *window;
+ GtkWidget *focus;
gboolean handled;
g_return_val_if_fail (GTK_IS_WINDOW (widget), FALSE);
@@ -3493,10 +3494,31 @@ gtk_window_key_press_event (GtkWidget
window = GTK_WINDOW (widget);
handled = FALSE;
-
- if (window->focus_widget && window->focus_widget != widget &&
- GTK_WIDGET_IS_SENSITIVE (window->focus_widget))
- handled = gtk_widget_event (window->focus_widget, (GdkEvent*) event);
+
+ focus = window->focus_widget;
+ if (focus)
+ g_object_ref (focus);
+
+ while (!handled &&
+ focus && focus != widget &&
+ gtk_widget_get_toplevel (focus) == widget)
+ {
+ GtkWidget *parent;
+
+ if (GTK_WIDGET_IS_SENSITIVE (focus))
+ handled = gtk_widget_event (focus, (GdkEvent*) event);
+
+ parent = focus->parent;
+ if (parent)
+ g_object_ref (parent);
+
+ g_object_unref (focus);
+
+ focus = parent;
+ }
+
+ if (focus)
+ g_object_unref (focus);
if (!handled)
handled = gtk_window_mnemonic_activate (window,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]