After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 101309 - No-alt for menubar accelerators during navigation
No-alt for menubar accelerators during navigation
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkMenu
2.1.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
AP3
Depends on:
Blocks:
 
 
Reported: 2002-12-15 21:51 UTC by Owen Taylor
Modified: 2011-02-04 16:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch adding and using GtkMnemonicHash (28.31 KB, patch)
2002-12-15 21:52 UTC, Owen Taylor
none Details | Review
update (27.83 KB, patch)
2004-12-09 15:21 UTC, Matthias Clasen
none Details | Review

Description Owen Taylor 2002-12-15 21:51:59 UTC
Right now, if you hit F10 to go the menubar, you still
need to hit Alt-letter to access the mnemonics on the menubar.

Fixing this is rather difficult because the mnemonics
on the menubar need to be used in two contexts:

 A) With the alt-key and conflict resolved with all
    other accelerators on the toplevel normally
 
 B) Without the alt-key and conflict resolved only
    with the menubar accelerators during navigation.

The attached patch handles this by separating the mnemonic
resolution parts of GtkWindow into a separate GtkMnemonicHash
object, and making GtkMenuShell maintain it's own
MnemonicHash that is used during navigation.

One could also take the MnemonicHash idea in a different
direction and dynamically construct a MnemonicHash on
keypress during navigation and use that to resolve conflicts
between the mnemonics on _all_ visible menus. That might
be a little slow. (The function you'd need there is 
gtk_mnemonic_hash_merge() to construct a composite mnemonic
hash.)

An completely different approach to go would be to not split
mnemonic hashes out at all, but to have a GtkWindow
function like _gtk_window_activate_key() that only activated
mnemonics in a single portion of the widget heirarchy;
going that way:

 a) Key resolution wouldn't be restricted to the the
    menu bar accelerators. (But if Alt-<key> worked with
    the menu not popped up, then <key> would work during
    navigation.)

 b) There would be no natural extension to conflict resolution
    between accelerators on multiple menus.

But it probably would be a lot simpler.
Comment 1 Owen Taylor 2002-12-15 21:52:53 UTC
Created attachment 13009 [details] [review]
Patch adding and using GtkMnemonicHash
Comment 2 Owen Taylor 2002-12-15 21:59:02 UTC
Downsides of the attached patch are:

 - It's a bit large (around 300 new lines of code)
 - It breaks putting GtkLabel cut-and-paste widgets with
   mnemonic widgets into a menu since GtkLabel now
   has to do something different when inside a GtkMenuShell.
  
   
Comment 3 Calum Benson 2004-10-21 16:44:16 UTC
Apologies for spam-- ensuring Sun a11y team are cc'ed on all current a11y bugs.
 Filter on "SUN A11Y SPAM" to ignore.
Comment 4 Matthias Clasen 2004-12-09 15:21:47 UTC
Created attachment 34664 [details] [review]
update

Here is an update which works against current cvs HEAD
Comment 5 bill.haneman 2004-12-09 15:37:16 UTC
Would be very nice to have this.  Thanks Matthias!  It is kind of a big patch,
but it will help keyboard-only and blind users a lot.
Comment 6 Matthias Clasen 2004-12-09 15:42:59 UTC
It only works once, though.

Ie you can F10 to the menubar (and leave the focus on the menubar), 
then use e.g E to go to the edit menu,
but after that, the focus is inside the edit menu, so pressing F doesn't
bring you back to the file menu, but activates whatever item has F as mnemonic
inside the edit menu.
Comment 7 Matthias Clasen 2004-12-10 22:08:43 UTC
2004-12-10  Matthias Clasen  <mclasen@redhat.com>

	Support no-Alt mnemnonics in menu bars  (#101309, Owen Taylor)
	
	* gtk/gtkwindow.c: Factor out mnemonic hash code into
	a separate file.

	* gtk/gtkmnemonichash.[hc]: Factored out mnemonic hash
	code from gtkwindow.c.

	* gtk/Makefile.am (gtk_c_sources): Add gtkmnemonichash.[hc].

	* gtk/gtkmenushell.c (struct _GtkMenuShellPrivate): Give 
	menu shells their own mnemonic hash.

	* gtk/gtkmenushell.h: Add private api to support mnemonics.

	* gtk/gtklabel.c (gtk_label_setup_mnemonic): Add mnemonic to
	the menushell mnemonic hash when inside a menu.
Comment 8 Robert Ögren 2004-12-12 17:44:52 UTC
Matthias, I think there's a copy'n'paste error in gtk_label_setup_mnemonic:

      if (label->mnemonic_window)
        {
          gtk_window_remove_mnemonic  (label->mnemonic_window,
                                       last_key,
                                       widget);
          label->mnemonic_window = NULL;
        }
      if (mnemonic_menu)
        {
          _gtk_menu_shell_remove_mnemonic (GTK_MENU_SHELL (mnemonic_menu),
                                           last_key,
                                           widget);
          label->mnemonic_window = NULL;

          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                      HERE


Shouldn't it set mnemonic_menu = NULL or something instead?

I tried running latest gtk+ from CVS with GIMP 2.0.6 (on WinXP), and get the
following assertion which I think is caused by the above.

(gimp-2.0.exe): Gtk-CRITICAL **: _gtk_mnemonic_hash_remove: assertion `targets
&& g_slist_find (targets, target) != NULL' failed

  • #0 g_log
    at gmessages.c line 506
  • #1 g_return_if_fail_warning
  • #2 _gtk_mnemonic_hash_remove
    at gtkmnemonichash.c line 98
  • #3 _gtk_menu_shell_remove_mnemonic
    at gtkmenushell.c line 1378
  • #4 gtk_label_setup_mnemonic
    at gtklabel.c line 853
  • #5 gtk_label_hierarchy_changed
    at gtklabel.c line 897

Comment 9 Matthias Clasen 2004-12-12 18:12:11 UTC
I think you are correct. Does this fix it for you ?

2004-12-12  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtklabel.c (gtk_label_setup_mnemonic): Fix a 
	copy-and-paste error, noticed by Robert Ögren.
Comment 10 Robert Ögren 2004-12-14 22:28:04 UTC
Matthias, yes that fixed it. Thanks.