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 143007 - popup menu: keyboard accelerator does not work while menu is visible
popup menu: keyboard accelerator does not work while menu is visible
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Class: UIManager / Actions
2.6.x
Other Linux
: High normal
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2004-05-23 20:01 UTC by Timothy M. Shead
Modified: 2007-09-02 17:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Timothy M. Shead 2004-05-23 20:01:12 UTC
* Build the popup menu sample from examples/book/menus/popup.
* Run it.
* Right-click in the window that opens.
* Popup menu appears; one item has an accelerator "Ctrl+P".
* Try to activate the accelerator using the keyboard.
* Nothing happens.

I've verified this with both gtkmm-2.2.11 and gtkmm-2.4.1
Comment 1 Murray Cumming 2004-10-25 11:38:34 UTC
Changing version to 2.4, so that I see this.
Comment 2 Murray Cumming 2004-11-03 12:01:20 UTC
I have updated this example to use GtkUIManager, by the way.

The accelerator (Ctrl+P) does work, but not while the popup menu is visible. I
guess we need to check whether it works in C.
Comment 3 Murray Cumming 2005-03-03 11:58:32 UTC
I suspect that it would work if the menu item was also in a regular menu bar.
Popup menus should just be shortcuts to existing menu items anyway, and I guess
that's why they don't also show the keyboard shortcut in the popup menu.

Reassigning to GTK+, who may disagree, and may require a C test case.
Comment 4 Matthias Clasen 2005-04-06 19:53:30 UTC
We are following the Gnome HIG here, actually:

"Provide an access key for each item. However, to enhance their spatial
efficiency and readability, do not show keyboard shortcuts in popup menus."

If you disagree, please reopen against the HIG. 
Comment 5 Hans Breuer 2006-06-05 17:47:19 UTC
Given that The GIMP people have written a bunch of code to have the accelerators back in their "context menus" - and given that Dia now also uses GtkUIManager and
thus has to either lack the accelerators or cut and paste a lof of code to resurrect them:
Could there please be some function in Gtk to reenable the accelerators in 
nested "context menus"? They may be bad from the HIG's point of view, but
IMO the toolkit should not enforce the HIG - just make it possible and
convenient to follow. And to violate it where appropriate.
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2007-08-19 20:59:37 UTC
I run into probably the same problem just now. I see the assigned key in the popup menu, but pressing it has no effect :/

self->priv->accel_group=gtk_accel_group_new();

self->priv->context_menu=gtk_menu_new();
gtk_menu_set_accel_group(GTK_MENU(self->priv->context_menu), self->priv->accel_group);
  gtk_menu_set_accel_path(GTK_MENU(self->priv->context_menu),"<Buzztard-Main>/PatternView/PatternContext");

menu_item=gtk_image_menu_item_new_with_label(_("New pattern  ..."));
image=gtk_image_new_from_stock(GTK_STOCK_NEW,GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item),image);
gtk_menu_item_set_accel_path (GTK_MENU_ITEM (menu_item), "<Buzztard-Main>/PatternView/PatternContext/NewPattern");
gtk_accel_map_add_entry ("<Buzztard-Main>/PatternView/PatternContext/NewPattern", GDK_Insert, GDK_CONTROL_MASK|GDK_SHIFT_MASK);
gtk_menu_shell_append(GTK_MENU_SHELL(self->priv->context_menu),menu_item);
gtk_widget_show(menu_item);
g_signal_connect(G_OBJECT(menu_item),"activate",G_CALLBACK(on_context_menu_pattern_new_activate),(gpointer)self);

gtk_window_add_accel_group(GTK_WINDOW(main_window),self->priv->accel_group);
Comment 7 Stefan Sauer (gstreamer, gtkdoc dev) 2007-09-02 17:00:51 UTC
My issue is now fixed as of Bug #469374. Not sure if that fixes the issue of the reporter for this bug.