Re: Submenu inside popup menu problems

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

 



I recently encountered what I thought was flaky behaviour with gtk menus, but in the end it turned out to be a feature.

What I found was that I was bringint the original menu up with the right mouse button and then selecting a sub-menu entry with the left button.    Now it appears that whatever button is passed into the call to gtk_menu_popup() has to be the same one that is used to select an entry from a submenu.   Any other button just dismisses the menu.  

This behaviour can be quite useful once you know it works that way (although for some reason you can use any button to select items from the top-level menu).

Anyway, I changed my code to pass in 0 as the button and now I can use any mouse button to select from subitems.

I'm guessing you are running into the same issue.

John


Miroslav Rajcic wrote:
Submenu inside popup menu problems

I've created popup menu with its submenu using code like below. Submenu is
displayed ok, but the problem is no
handler functions are called when submenu item gets clicked (all other popup
menu items work ok).

Can anyone spot the error ?

Thanks,
  Miroslav Rajcic


GtkWidget *menu, *submenu;
 GtkWidget *menu_item, *move_item;
 int button, event_time;

 menu = gtk_menu_new ();

 //add menu items
 menu_item = gtk_menu_item_new_with_label("Insert Node\tIns");
 g_signal_connect(GTK_OBJECT (menu_item), "activate", G_CALLBACK
(on_menu_insert_node), NULL);
 gtk_menu_append(menu, menu_item);
 gtk_widget_show (menu_item);  // Show the widget

 move_item = gtk_menu_item_new_with_label("Move Node");
 gtk_menu_append(menu, move_item);
 gtk_widget_show (move_item);  // Show the widget

 submenu = gtk_menu_new ();

 menu_item = gtk_menu_item_new_with_label("Up    \tShift+Up");
 gtk_menu_append(submenu, menu_item);
 g_signal_connect(GTK_OBJECT (menu_item), "activate", G_CALLBACK
(on_menu_move_up), NULL);
 gtk_widget_show (menu_item);  // Show the widget

 gtk_menu_item_set_submenu (GTK_MENU_ITEM (move_item), submenu);

 gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, NULL, button,
event_time);


_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux