ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 29日 (月) 07:24:19 JST
------------------------- REMOTE_ADDR = 74.14.158.59 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-popup ------------------------- @@ -46,7 +46,8 @@ window.show_all Gtk.main -This short example shod give you a good idea, about creating a pop-up menu. We started by creating the menu, adding to it two menu items. Note, from Gtk::Widget inherited 'show_all' method which you have to run after you set up your menu. Though, at this point not yet essential, but eventually required is the code to connect menu's((*'activate'*))signal to callbacks. The last is a rather important step directly related to pop-up menu implementation, which depending on the capabilities of the widget to which the menu is going to be attached, can be accomplished in more ways. Simpler ones are the two we use here in our bare-bones pop-up menu example, since window provides or inherits all necessary behaviours. Here we need to to mention at least window's((*button-press-event*))signal which it inherits from Gtk::Widget. This signal is emitted when a user clicks 'right-mouse-button', and is used in windows' signal handler to open the pop-up menu. +This short example shod give you a good idea, about creating a pop-up menu. We started by creating the menu, adding to it two menu items. Note, from Gtk::Widget inherited 'show_all' method which you have to run after you set up your menu. Though, at this point not yet essential, but eventually required is the code to connect menu's((*'activate'*))signal to callbacks. The last is a rather important step directly related to pop-up menu implementation, which depending on the capabilities of the widget to which the menu is going to be attached, can be accomplished in more ways. Simpler ones are the two we use here in our bare-bones pop-up menu example, since window provides or inherits all necessary behaviours. Here we need to to mention at least window's((*'button-press-event'*))signal which it inherits from Gtk::Widget. This signal is emitted when a user clicks 'right-mouse-button', and is used in windows' signal handler to open the pop-up menu. + # Make window sensitive to Right-mouse-click, to open the pop-up menu. window.add_events(Gdk::Event::BUTTON_PRESS_MASK)