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 89336 - Keynav issue in menubar
Keynav issue in menubar
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: GtkMenu
unspecified
Other other
: Normal major
: Medium feature
Assigned To: gtk-bugs
gtk-bugs
AP2
: 82110 93068 127418 161751 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2002-07-29 13:43 UTC by Muktha
Modified: 2015-07-20 22:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (535 bytes, patch)
2002-08-02 13:27 UTC, padraig.obriain
rejected Details | Review
make all menu mnemonics work (1.42 KB, patch)
2004-12-29 06:01 UTC, Matthias Clasen
needs-work Details | Review

Description Muktha 2002-07-29 13:43:17 UTC
Unable to select any menuitem with mnemonics when the focus is only on
the menubar and not on any of the menuitems.

Steps to simulate the problem :
1. Open any application Eg:Gnome-charactermap.
2. Press F10 - The first menu will be opened and the focus will remain on
                the menubar.
3. It is not possible to select any of the menuitems with their
corresponding mnemonics. 
   
For example in Character-map, pressing F10 will open the 'Characters'
menu. It is not possible then to select the 'Browse' menuitem by pressing
'b'.
Comment 1 Owen Taylor 2002-07-30 03:51:48 UTC
I'm not sure that should work; though if it isn't supposed
to work, you probably should be able to get to the other
menubar items with C/E/H rather than <Alt>C/<Alt>E/<Alt>H.


Comment 2 Calum Benson 2002-07-30 11:37:22 UTC
It should work, and indeed it does for me in Sun's beta 1 in every app
I tried *except* character map.  (If it's broken everywhere now, this
sounds like a fairly serious regression keynav-wise.)

Character map did have some other weird menu keynav problems though
(see point 2 in bug #87907)-- could this be related?  Gman claims to
have fixed this but, superstar though he is, he fixed it so quickly
that I'm not convinced he really got to the root of the problem :)
Comment 3 Muktha 2002-07-30 13:09:38 UTC
I took the latest sources (from CVS head) and I observed the above
mentioned problem in gnome-dictionary, gnome-calculator,
gnome-search-tool also. 

However, this problem is not present in case of eog and gedit, and it
is possible to select the menuitem by pressing the mnemonic even if
the focus is not present on any of the menuitems.
I have noticed that in these applications, the menu is created using
.xml files.
Comment 4 Calum Benson 2002-07-30 13:22:53 UTC
Hmm... well, whatever's causing it, we need to get to the bottom of
it-- this sort of inconsistency is a definite accessibility issue. 
Bumping up the severity/priority one notch accordingly, hope you don't
mind, Luis :)
Comment 5 padraig.obriain 2002-08-02 08:50:09 UTC
I have had a look at what is happening in gnome-calculator and gedit.

In both cases, when the mnemonic is pressed on the keyboard a GdkEvent
of type GDK_KEY_PRESS occurs. The function gtk_propagate_event() is
called and as the event type is GDK_KEY_PRESS and the widget on which
the event occurred is a GtkMenu which is grab widget the event is sent
to the GtkMenu by the statement "handled_event = gtk_widget_event
(widget, event);". This causes a "key_press_event" signal to be
emitted on the GtkMenu.

In gnome-calculator, the default handler for the "key_press_event"
signal, gtk_menu_key_press() is called. This always returns TRUE so
the call to gtk_widget_event() returns TRUE. The event is handled so
no more processing of the event occurs.

The claim is that this behavior has changed since Sun Beta 1. Perhaps,
Owen can jump in here and suggest what has changed since the end of
May to cause such a change.

In gedit, we are using libbonoboui rather than vanilla GTK. When a
menu is created a signal handler sucking_gtk_keybindings_cb() is
connected to the key_press_event" signal for a GtkMenu. When the
"key_press_event" is emitted on the GtkMenu the function
sucking_gtk_keybindings_cb() is called before the default signal
handler.

This function calls gtk_menu_shell_key_press(), the default handler
for "key_press_event" signal for GtkMenuShell which returns FALSE. 
The signal emission is stopped so the default signal handler,
gtk_menu_key_press() is not called and sucking_gtk_keybindings_cb()
returns FALSE. Thus, gtk_widget_event() returns FALSE in
gtk_propagate_event(). As the event is not handled it is sent to the
top level window, which causes the mnemonic to be activated.

Comment 6 Calum Benson 2002-08-02 11:34:32 UTC
Acutally, it turns out this hasn't changed since Sun beta 1... I just
coincidentally happened to test applications that worked as expected! 
I can confirm that the behaviour is "broken" in calculator etc. on
beta 1 as well, but works as expected in gedit and EOG as Muktha said.
Comment 7 Owen Taylor 2002-08-02 13:02:19 UTC
I doubt anything changed; it sounds like someone hacked
around a problem they saw with the GTK+ keybindings in
Bonobo, rather than trying to get the problem actually
fixed in GTK+.
Comment 8 padraig.obriain 2002-08-02 13:27:39 UTC
Created attachment 10221 [details] [review]
Proposed patch
Comment 9 padraig.obriain 2002-08-13 10:18:16 UTC
Any comments on the appropriateness of attached patch?
Comment 10 Narayana Pattipati 2002-09-05 14:14:45 UTC
Padraig,

I have applied this patch on latest sources and found that it is
working as expected for many applications except for gnome-calculator. 

Steps:

1. Press F10. Gives focus to File menu. 
2. Press Q now. This will invoke the Quit button and closes the menu.
3. Next time, launch the application, press F10. It gives focus to
the    File menu. 
4. Now with Right arrow key, give focus to Help menu. Now pressing    
   C(mnemonic for Contents) should invoke the gnome-help OR        
   pressing A(mnemonic for About) should invoke the gnome about.
But      this is not happening.

I am just wondering why only gnome-calculator fails.?
Comment 11 padraig.obriain 2002-09-06 09:40:05 UTC
The problem with gnome-calculator is that accelerators are defined in
gnome-utils/gcalc/gnome-calc.c for most of the first letters on the
buttons.

When you type a or c as in your test, the function
gtk_menu_shell_key_press() is called. As the menu shell does not have
an active menu item and does have a parent shell the key press event
is npased to the parent menu shell. This menu shell is the menu bar so
the accelerators defined on the main window are looked at.

Notice that when C is typed the value 0 in the calculators entry field
changes to 1 as the cosine has been calculated.

It looks like the mnemonics on the menu items in the first level menus
should not clash with the accelerators defined in the application. 
Comment 12 bill.haneman 2002-10-08 14:10:07 UTC

*** This bug has been marked as a duplicate of 94357 ***
Comment 13 Owen Taylor 2002-10-08 14:52:31 UTC
Did you really mean to dup this, Bill? It doesn't look related.
Comment 14 padraig.obriain 2002-10-17 09:32:57 UTC
If consistency ofg behavior is what is required I think that we would
be better off removing the function sucking_gtk_bindings_cb() from
libbonoboui.

We need to understand what the effect will be before doing it.
Comment 15 Owen Taylor 2002-10-17 22:00:43 UTC
Padraig's patch I'd consider definitely wrong ... it happens
to work because it has the effect that if the key press isn't
handled at all, the default handler for the window gets
called which runs the mnemonics again. 

But that's not the intent of the code ... the intent
of the code is that all keypress handling happens in
gtk_menu_key_press and gtk_menu_shell_key_press -- 
mnemonics are already handled in gtk_menu_shell_key_press():

That's what:

  toplevel = gtk_widget_get_toplevel (widget);
  if (GTK_IS_WINDOW (toplevel) &&
      _gtk_window_activate_key (GTK_WINDOW (toplevel), event))
    return TRUE;

is for. (The code that is causing problems for gcalc)

The reason that it isn't triggering here is that we explicitely
set things up so that the domain of activation is the menushell
with the deepest selected menu item, not the deepest menu
shell. This is what:

  if (!menu_shell->active_menu_item && menu_shell->parent_menu_shell)
    return gtk_widget_event (menu_shell->parent_menu_shell, (GdkEvent
*)event);

in gtk_menu_shell_key_press() is for.

It would strike me as weird if the rules for what accelerators
are active are different for menu items in menu bras and menu
items with submenus in menu items. As I said at earlier:

 "...you probably should be able to get to the other
 menubar items with C/E/H rather than <Alt>C/<Alt>E/<Alt>H."

But I wouldn't expect to be able to select menu items in
the menus with the mnemonics when deepest menu selected
is the menuitem on the menu bar.

Why did you say "It should work", Calum? Just because it worked
in apps where Bonobo was in use? Or for useability reasons?

On most toolkits, the submenus won't be posted when you hit
F10, so you definitely wouldn't expect to be able to use
the mnemonics for the items in them.


Comment 16 Owen Taylor 2002-10-17 22:33:39 UTC
*** Bug 82110 has been marked as a duplicate of this bug. ***
Comment 17 Calum Benson 2002-10-18 12:03:42 UTC
> Why did you say "It should work", Calum? Just because it worked
> in apps where Bonobo was in use? Or for useability reasons?

I said "it should work" because whenever the user sees a menu posted
on the screen, they should be able to activate one of its items by
pressing its access key-- that's just a fundamental expectation.

> On most toolkits, the submenus won't be posted when you hit
> F10, so you definitely wouldn't expect to be able to use
> the mnemonics for the items in them.

I think you've hit the nail on the head there... as you say, when you
press F10 on Windows, no menu is popped up, and only the access keys
for the menu titles are active.  I still think the way we do it is
more useful when it works as expected (i.e. as it does in bonobo
apps), but if the only way we can get it to work consistently is to
copy the Windows behaviour for both types of app then I guess I
wouldn't have a big problem with that either.
Comment 18 bill.haneman 2002-10-18 17:17:01 UTC
OK, my 2c worth:

If the mnemonic is displayed, it should work.  If it doesn't work, it
shouldn't be displayed.

From there I conclude that either 

#1) F10 should only focus the menubar but not post any menus, 

OR 

#2) F10 should post the first menu in the menubar and all mnemonics on
that posted menu should work (*not* the menubar).  

Of course whichever way we go, it should be consistent across the
desktop, especially vis-a-vis bonobo stuff.

Java does what Calum is suggesting (option #1); thus I would much
prefer sticking with that model, since otherwise we have inconsistency
(and thus accessibility problems).

-Bill

Comment 19 Calum Benson 2002-10-18 19:07:35 UTC
Correction: Java actually does mostly what we originally wanted to do,
i.e. option #2 :)

When you press F10 in Java, the first menu pops up but focus stays on
the title.  At this point the mnemonics on both the posted menu *and*
the other menu titles are available; I'm not sure which takes priority.
Comment 20 Calum Benson 2002-10-24 19:54:46 UTC
(Just adding comments in response to Owen's recent "what should we 
fix for 2.2" email)

I don't really have anything new to add, just that IMHO this is 
probably one of the more serious problems on Owen's list of things 
to consider fixing for 2.2, whether it be by implementing methods 1 
or 2 above or something else we haven't thought of yet :)
Comment 21 bill.haneman 2002-11-22 09:41:30 UTC
Calum is right, this is one of the more pressing UI issues in 2.1.X
relating to gtk+.  We feel that we urgently need a solution for
accessibility reasons, thus I believe we really need an agreed-upon
solution for 2.2.  We need at least to agree on behavior and create a
patch in the next couple of weeks, even if the final implementation
code differs from the patch's code.
Comment 22 Balamurali Viswanathan 2002-11-29 10:55:25 UTC
*** Bug 93068 has been marked as a duplicate of this bug. ***
Comment 23 Owen Taylor 2002-12-09 21:17:40 UTC
*** Bug 93068 has been marked as a duplicate of this bug. ***
Comment 24 Owen Taylor 2002-12-10 03:23:42 UTC
There seems to be a desire for change here, but it isn't
clear to me what the desired behavior *is*.

Some implementation constraints for any 2.2. changes:

 A) If an item with a menu attached is selected (either an
    item on the menubar, or a menu item with a submenu),
    then the attached menu will be posted.

 B) Insensitive menu items cannot be selected.

Changing either of these is a significant amount of work
that is not feasible at the current time.

The current behavior is:

 Only the mnemonics in the deepest menu with a selected
 item are available.

Things I could do:

 1) Make the mnemonics on the menu bar work with Letter
    instead of Alt-Letter when navigating the menu. (Easy)

 2) Search some set of other menus _after_ the deepest
    menu with a selected item. (Easiest if the direction
    of searching is always upwards; searching menus
    deeper in the heirarchy would require bad hackery.)

    Typical conflict-resolution "cycle and don't select"
    is not doable for 2.2.

Neither of these actually solves the bug 93068, which seems
like the most urgent problem to me. I sense that there
are concerns about other issues here, but I'm really
not sure what those issues are.

To fix bug 93068, probably the easiest thing is to simply
go back on revisit the earlier decision:;

 - If the first item in the menu is not sensitive when
   the menu is activated, then focus the parent menu
   item for the menu.

and change that to:

 - If the first item in the menu is not sensitive when
   the menu is activated, then focus the next sensitive
   menu item.

Would that address the concerns here for now? Would the
combination of that and either of 1) or 2) address
the immediate concerns?
Comment 25 Owen Taylor 2002-12-15 22:02:09 UTC
After some hacking and investigation of no-alt-for-menubar 
accelerators, I filed bug 101309. The code in there
works, but it's far too big (1000 line patch) and intrusive
to go in at this point for 2.2.0.
Comment 26 Owen Taylor 2002-12-15 23:34:30 UTC
I made a simple (s/FALSE/TRUE/) change that should fix
the worst of the problems. We can investigate more 
ambitious changes for 2.4.

Sun Dec 15 18:14:16 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkmenuitem.c (gtk_real_menu_item_activate_item):
        Pass TRUE for search_sensitive - prevents a problem
        where after hitting Alt-F to bring up the File menu,
        the mnemonics for the items in the menu might not
        be usable. (#89336)

Comment 27 padraig.obriain 2003-01-03 10:32:43 UTC
The original problem reported in this bug is still present.

1) Run gnome-character-map.
2) Press F10.; the menu with items Browse and Quit are now visible.
3) The visible menu items Browse and Quit cannot be activated using
the keyboard.

From Owen's comments of December 9th, if the selected item of the
deepest menu with a selected item has a submenu would it be possible
to make the mnemonics in that menu available?

From Owen's comments I understand that the submenu will be posted.
Doing this would "require bad hackery" but I think that this is what
Calum and Bill are asking for in their comments of October 18th.
Comment 28 Owen Taylor 2003-01-03 23:53:59 UTC
Any further action here needs to be done in a framework like
that discussed in bug 101309. I dont' think additional hackery
for 2.2.x makes sense.
Comment 29 Rajkumar 2003-03-21 06:42:52 UTC
I discussed with Owen on the possible solutions for this issue and the
available options as stated earlier above are:

a) F10 should post the first menu in the menubar and all mnemonics of
the posted menu should work (or)

b) F10 should only focus the first menu title in the menubar and
should not post the menu

From the discussions I guess implementing part-a will require fairly
large amount of code changes and complicated too. 


Owen suggested to try with part-b, IMHO I feel we should do the
following for part-b:

i)   F10 should focus the first menu title
ii)  Then either pressing space bar or down arrow should pop down the
menu
iii) Users should also able to pop down the menu by clicking on the
focussed menu title
Comment 30 padraig.obriain 2003-03-21 08:39:30 UTC
What will happen if left or right arrow is pressed after using F10 to
focus the first menu title? Is focus moved to the next or previous
menu title without posting its menu?
Comment 31 Rajkumar 2003-03-21 09:17:00 UTC
> Is focus moved to the next or previous menu title without posting
its menu?

Yes, I think its should move around without posting the menu.
Comment 32 Calum Benson 2003-03-27 19:30:50 UTC
Yes, that's how it works on Windows IIRC.
Comment 33 Calum Benson 2003-04-03 13:00:36 UTC
Updating status_whiteboard field to reflect A11Y team's assessment 
of accessibility impact.
Comment 34 bill.haneman 2003-06-26 22:55:11 UTC
OK, this is marked as a "stopper" for accessibility.  We need to agree
on the behavior we need ( I think we have ) and we need an
implementation.  How can we move forward on this?  THis bug has been
around a long time... 
Comment 35 Calum Benson 2003-08-07 16:18:42 UTC
Apologies for spam... marking as GNOMEVER2.3 so it appears on the official GNOME
bug list :)
Comment 36 Soren Sandmann Pedersen 2004-02-19 13:58:16 UTC
*** Bug 127418 has been marked as a duplicate of this bug. ***
Comment 37 bill.haneman 2004-03-08 22:06:33 UTC
owen - are you sure you really want to put this on 2.6.0?
there's been a patch for over a year (albeit one you consider wrong),
and this has been marked as an accessibility "stopper" for nearly two
years.  What are we doing wrong here?  Note also that the desired
behavior is the windoze behavior according to calum, and though we
don't want to take that as the gold standard, it does mean the
proposal isn't totally random.
Comment 38 bill.haneman 2004-03-08 22:08:51 UTC
correction - this was successively downgraded from "stopper" but from
calum's comments its apparent that this is pretty important and a
significant departure from other toolkits.
Comment 39 Calum Benson 2004-10-21 16:53:19 UTC
Apologies for spam-- ensuring Sun a11y team are cc'ed on all current a11y bugs.
 Filter on "SUN A11Y SPAM" to ignore.
Comment 40 Matthias Clasen 2004-12-12 05:59:32 UTC
We have the mnemonic hash factored out now, so we have no-Alt-mnemonics working
if the focus is in the menubar, and it should be possible to make the mnemonic
resolution in menus look at mnemonics in multiple menus. We're probably not
going to get to that for 2.6.0, though.
Comment 41 Matthias Clasen 2004-12-29 06:01:15 UTC
Created attachment 35263 [details] [review]
make all menu mnemonics work

Here is a first attempt at making all displayed mnemonics work. 
Note that my patch does not try to construct a merged hash and
resolve conflicts across multiple menus. Instead, I look at the 
hashes of the current menu shell, an open submenu and the parent
shells (in that order), and cycle only between the matches in the 
first menu shell where the mnemonic is found. 
Cycling between matches across multiple menus might not work 
very well, since selecting a match in some other menu can affect 
the menu hierarchy, thus change the set of matches and cause 
cycling to "get stuck".

Regarding the lookup order in the patch, it might be better to
prefer matches in the open submenu over matches in the current 
shell, at least if the current shell is a menubar.
Comment 42 Matthias Clasen 2005-01-03 06:12:18 UTC
*** Bug 161751 has been marked as a duplicate of this bug. ***
Comment 43 Matthias Clasen 2005-01-03 19:38:15 UTC
After discussing this with Owen a bit, cycling should perhaps freeze changes to
the visual menu hierarchy. Items should be selected, not activated.
Comment 44 bill.haneman 2005-01-05 11:17:53 UTC
What does windoze do vis-a-vis cycling?  Remember, the most critical audience
for this feature will have preexisting expectations.
Comment 45 Calum Benson 2005-01-11 16:17:57 UTC
As far as I remember, Windows cycles only within the menu bar (i.e. between menu
titles with clashing mnemonics) when a menu title has focus, and only within the
most-recently posted menu when a menu has focus.  So it will never cycle between
a menu item and a menu title, for example.
Comment 46 Matthias Clasen 2005-01-11 16:39:42 UTC
Ah, as Owen is getting into GTK+,Cairo/win32 development, he can maybe test that
on his XP box...
Comment 47 Matthias Clasen 2005-01-13 19:07:40 UTC
We spent some time looking at the IE menu behaviour on Owens XP box, 
and observed:
- they have states where 
  a) mnemonics are shown but do not work
  b) mnemonics are not shown but work
- mnemonics only work in the innermost menu, even if the selected 
  item is in the parent menu
- cycling is done only within a single menu
- popup-after-timeout is done only with mouse navigation, never
  for keynav

What does that mean for us ? I think we should try the following
tweaks:
- restrict popup-after-timeout to mouse navigation
- make esc unpost the innermost menu instead of collapsing
  the entire hierarchy
- maybe make left-arrow unpost the innermost menu as well
- don't show underlines in menus where they do not work
Comment 48 Calum Benson 2006-04-26 17:13:11 UTC
Apologies for spam... ensuring Sun a11y folks are cc'ed on all current accessibility bugs.
Comment 49 Matthias Clasen 2015-07-20 22:09:24 UTC
After all this time, I think it is time to admit this won't be fixed