Re: How to make menu popdown?



Thanks for you answer.
Maybe my poor english confuse you,i want to create a submenu,items of this submenu should be horizontally array.So i firstly create a menu item of this submenu,it contains a hbox,hbox contains four buttons. I expect when i click one button,the submenu and its super menu could be popdown. My code is below,i expect when i click widget m_wiSubMenuButton1(or ..Button2..),menu m_wiMenuControl could be popdown.
Any advice is welcome,thanks.

...
m_wiMenuBar = gtk_menu_bar_new ();
m_wiMenuBtn = gtk_menu_item_new_with_label ("Control");
m_wiMenuControl = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (m_wiMenuBtn), m_wiMenuControl);

m_wiMenuItem1 = gtk_menu_item_new_with_label("Item1");
gtk_container_add (GTK_CONTAINER (m_wiMenuControl), m_wiMenuItem1);
m_wiMenuItem2 = gtk_menu_item_new_with_label("Item2");
gtk_container_add (GTK_CONTAINER (m_wiMenuControl), m_wiMenuItem2);
m_wiMenuItem3 = gtk_menu_item_new_with_label("Item3");
gtk_container_add (GTK_CONTAINER (m_wiMenuControl), m_wiMenuItem3);

m_wiSubMenu = gtk_menu_new();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (m_wiMenuItem3), m_wiSubMenu);
m_wiSubMenuItem1 = gtk_menu_item_new_with_label("SubMenuItem1");
gtk_container_add (GTK_CONTAINER (m_wiSubMenu), m_wiSubMenuItem1);
m_wiSubMenuHBox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (m_wiSubMenuItem1), m_wiSubMenuHBox);

m_wiSubMenuButton1 = gtk_button_new();
gtk_box_pack_start (GTK_BOX (m_wiSubMenuHBox), m_wiSubMenuButton1, FALSE, FALSE, 5);
m_wiSubMenuButton2 = gtk_button_new();
gtk_box_pack_start (GTK_BOX (m_wiSubMenuHBox), m_wiSubMenuButton2, FALSE, FALSE, 5);
m_wiSubMenuButton3 = gtk_button_new();
gtk_box_pack_start (GTK_BOX (m_wiSubMenuHBox), m_wiSubMenuButton3, FALSE, FALSE, 5);
m_wiSubMenuButton4 = gtk_button_new();
gtk_box_pack_start (GTK_BOX (m_wiSubMenuHBox), m_wiSubMenuButton4, FALSE, FALSE, 5);


From: Gus Koppel <gtk spamkiller bytechase cx>
To: <gtk-app-devel-list gnome org>
Subject: Re: How to make menu popdown?
Date: Thu, 28 Aug 2003 20:35:26 +0200

"Wang Wallice" wrote:

> To realize horizontal menu,i create a menu item,it contains a hbox,hbox
> contains four buttons.My problem is when i click one button,whole menu
> couldn't popdown. I try to emit signal "activate" to menu item,but it
> still doesn't work. Thanks!

Have you considered making use of the standard GTK features for menu bars
(horizontal menus) or have I misunderstood your intention? Menu bars make
popping down of submenus rather easy. have a look at the GtkMenu class and
relatives (GtkMenuBar, GtkMenuItem)  the GTK reference.

Nevertheless you could use buttons in hboxes as well to trigger popdown
(or popup) menus but that's both potentially confusing to users and a bit
more complicated. You'd still have to prepare a popup menu. Just trying to
activate some GtkMenuItems isn't sufficient.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn



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