ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 30日 (火) 21:08:30 JST
------------------------- REMOTE_ADDR = 74.14.158.59 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-mnui ------------------------- @@ -15,18 +15,20 @@ ## See: menuitems-n-submenus-mechanics.rb menu = Gtk::Menu.new - mitem1 = Gtk::MenuItem.new("Test1") - mitem2 = Gtk::MenuItem.new("Test2") - menu.append(mitem1) - menu.append(mitem2) + top_mitem1 = Gtk::MenuItem.new("Top Item 1 (final)") + top_mitem2 = Gtk::MenuItem.new("Top Item 2 (submenu)") + menu.append(top_mitem1) + menu.append(top_mitem2) + submenu = Gtk::Menu.new - ['Sub Item 1', 'Sub Item 2', 'Sub Item 3'].each do |mi| - menuitem = Gtk::MenuItem.new(mi) - submenu.append(menuitem) - menuitem.show + ['Sub Item 1 (final)', 'Sub Item 2 (final)', 'Sub Item 3 (final)'].each do |mi| + menuitem = Gtk::MenuItem.new(mi) + submenu.append(menuitem) + menuitem.show end submenu.show - mitem2.submenu = submenu # submenu is actually Gtk::Menu + + top_mitem2.submenu = submenu menu.show_all