ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 23日 (火) 03:50:13 JST
------------------------- REMOTE_ADDR = 184.145.49.94 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-popup ------------------------- @@ -99,9 +99,9 @@ In most cases you will want to use ((*button-press-event*)) signal to detect when the user wants the pop-up menu to be shown. At this point you may also check whether the right mouse button (event.button == 3) was clicked. -Initially an empty pop-up menu is created. We use a helper method ((*create_popup_menu*)) to create and add (append) individual menu items to the menu. You could also use Gtk::MenuShell#prepend(child) or Gtk::MenuShell#insert(child, position). Finally we bind the menu items to the appropriate callback methods and the ((*activate*)) signal. +Initially an empty pop-up menu is created. We use a helper method ((*create_popup_menu*)) to create and add (append) individual menu items to the menu. You could also use Gtk::MenuShell#prepend(child) or Gtk::MenuShell#insert(child, position). Finally we bind the menu items to the appropriate callback methods and the((*activate*))signal. -I also found it unnecessary to call Gtk::Menu#attach_to_widget(attach_widget){|attach_widgt, menu| ... } in this program example, as required by the Andrew Klause's book and the C GTK+ example there, which I translated to Ruby for us here. +Also, in this example it is not at all necessary to call Gtk::Menu#attach_to_widget(attach_widget){|attach_widgt, menu| ... }, which sets the callback procedure (block) to be invoked when the menu calls Gtk::Menu#detach during its destruction. === Use MenuItem with no label as Separators in menus