GNOME Bugzilla – Bug 88630
Menu::popup() and item activation
Last modified: 2004-12-22 21:47:04 UTC
First I must notice that I'm not sure if it is a bug, a feature or perhaps a Gtk+ issue. When I create a popup menu with submenus subitems are not always activated. For example I have a menu: ------ Item 1 Item 2 --------- SubItem 1 SubItem 2 All items and subitems have on_activate signals connected. When I popup a menu using: menu->popup(*window, 3, 0); (3 is right mouse button), Item1 is activated no matter if I click it with left, middle or right mouse button. But subitems only are activated with right mouse button. Clicks with other buttons just close the menu. Replace 3 with 0 in popup() call and all items and subitems will be activated by any button. Such behaviour is a little strange. I think either all items should be activated with any button, or all with only one button. If it is not Gtkmm problem then I'm really sorry for trouble. I created a simple example showing this problem. It would be very useful if someone rewrote it in Gtk+ and test it then.
Created attachment 9970 [details] Example for above bug
I won't investigate this until someone proves that it's gtkmm only.
Gtk+ does exactly the same. Note that you shouldn't connect the popup action to the clicked signal. Please connect it to the button_press signal. Then you get the right parameters for the popup method from the GdkEventButton and you can do press-move-release actions to activate a popup menu item. I'll attach a slightly modified version of your example attachment.
Created attachment 10147 [details] Slightly modified example
Thanks Andreas. Well done. Of course buttons are for clicking, not right-clicking.