Re: Entry / TextBuffer that does not listen to accelerators?



On Fri, Sep 30, 2005 at 11:04:54 -0400, muppet wrote:

Stephan Brunner said:
I am not able to enter any 'u' into the Entry.

The reason this should work is, that the active widget gets the input.
If the widget does not handle it, it passes it on to it's parent. And so
on up to the window, which handles the accels.

Not quite; key events are delivered first to the toplevel window (an X quirk),
and propagated from there to child widgets.  gtk_window_key_press_event()
looks like this:

Hm. I thought that it was saner than this. But yes, actually the toplevel
window is above it's children, not below in X.

  static gint
  gtk_window_key_press_event (GtkWidget   *widget,
                          GdkEventKey *event)
  {
    GtkWindow *window = GTK_WINDOW (widget);
    gboolean handled = FALSE;

    /* handle mnemonics and accelerators */
    if (!handled)
      handled = gtk_window_activate_key (window, event);

    /* handle focus widget key events */
    if (!handled)
      handled = gtk_window_propagate_key_event (window, event);

    /* Chain up, invokes binding set */
    if (!handled)
      handled = GTK_WIDGET_CLASS (parent_class)->key_press_event (widget, event);

    return handled;
  }

Which means that window-wide mnemonics and accelerators take precedence over
per-widget keystrokes.  And, if you think about it, it *has* to work that way,
or something like a TextView would eat all of the keys that are supposed to be
menu accelerators.

No, it does not. I would even call it a bug. The event signal returns
a boolean, whether it handled the keypress or not. The logic should be
reversed. It should first propagate the event to the children and only handle
it if they did not handle it already. It would require each widget to
truthfuly return whether it handled the keypress, but it would behave saner.

By the way, how does it handle the tab switching? If you have an entry in the
tab order, you can tab into it, but you can't tab out, as the tab gets
inserted. That means that the container handles the tab only if it's child
did not. Or does the child handle it? That would sound mad.

--
                                                 Jan 'Bulb' Hudec <bulb ucw cz>

Attachment: signature.asc
Description: Digital signature



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