Re: Problems with underlined accelerator keys

Tim Janik wrote:
> On Sat, 28 Aug 1999, Damon Chaplin wrote:

> > I've recently added support for underlined accelerator keys in Glade so
> > that if you have a label with '_Hello' and an entry next to it, then
> > pressing Alt + H will set the focus to the entry.
> >
> > However, there is a problem if you use something like a notebook, since
> > you may have underlined accelerator keys on several pages and some of them
> > may clash.
> >
> > The general problem is that you typically only want these sorts of
> > accelerator keys to be active while the label or the target widget is visible.
> >
> > One solution may be to add another flag to GtkAccelFlags,
> > GTK_ACCEL_ONLY_IF_VISIBLE. Then when looking up an accelerator, these entries
> > are skipped if they are not currently visible.
> accelerators are a too generic thing for this, e.g. there might be multiple
> labels displaying a widget's accelerators or none. neither the accelerator
> itself, nor the widget that the accelerator is installed for have any knowledge
> of the widgets that display the accelerator bindings.
> the only thing we could actually check would be the visibility of the widget
> that the accelerator is installed on, *plus* the visibility of its anchestry.
> but that will fail for a notebook anyways, since a notebook only unmaps its
> pages and doesn't hide them. also a notbook page can just contain
> only accellabels (e.g. for an accelerator configuration dialog) and not the
> accelerated widgets itself, gtk really hasn't much of an idea when you want
> those accelerators to be active and when not.
> the correct aproach here is to group the accelerators together according to
> the notebook pages and remove/add those groups to the main window with the
> notebook page switches. we might want to add a more convenient interface in
> 1.3 that allowes for enabling and disabling of accelerator groups or
> individual accelerators even.

But what if you have notebooks inside notebooks? It starts getting very complicated,
and is too much work for the developer.

I don't see the problem with adding a flag like GTK_ACCEL_EMIT_ONLY_IF_VISIBLE.
There must be a test to check that the widget to emit the signal on is 'valid',
i.e. visible/mapped. This test would only be used when GTK_ACCEL_EMIT_ONLY_IF_VISIBLE
is set, so it won't affect existing apps.

The only slight problem is that GtkAccelGroup doesn't currently support multiple
entries with the same key + modifier combination. We'd need this if we are going to
support conflicting accelerator keys on different notebook pages. But for now we
could just skip this issue by creating accel groups for each notebook page, which is
a lot easier than adding/removing accel groups dynamically.

I suppose the ideal solution is for containers to handle these kinds of accelerators,
adding/removing accel groups dynamically as they switch pages or whatever.

I'll create a patch and test it out if there's any chance it will go into the next
1.2 release.


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