ruby-****@sourc*****
ruby-****@sourc*****
2012年 10月 27日 (土) 12:49:52 JST
------------------------- REMOTE_ADDR = 74.14.158.59 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-statb ------------------------- @@ -217,4 +217,4 @@ When working with signals we usually have to be concerned about the callback block parameters that are passed along when a callback is invoked. Especially when we use a single callback method for more than one different signals, like in our((*statusbar_hint*))method, we should rely on these parameters to identify which event occurred, and most likely which device (in our case menu item) emitted it. Both the((*'enter-notify-event'*))and((*'leave-notify-event'*))signals pass the signal emitting widget, as well as the event object whose type or class is Gdk::EventCrossing, the subclass of Gdk::Event class. This event object will provide us with the information, that will allow us to define whether we are dealing with a cursor entering or leaving a menu item. To identify whether the event was emitted by an entering or a leaving cursor in our signal handler callback we employ the Gdk::Event#event_type accessor method retrieving either Gdk::Event::ENTER_NOTIFY or Gdk::Event::LEAVE _NOTIFY event id value. -To identify the menu item's description status messages in our 'create_popup_menu' and finally in the callback 'statusbar_hint' method, we had to do some preparation work at the time when menu items were created. First we assigned the name to all our menu items by calling Gtk::Widget#name= on these objects. We use this name in two places: (1) first in 'create_popup_menu' method where we store status messages in a hash by using menu item's name is the key, and (2) in the callback - signal handler method (statusbar_hint), where we use this hash to retrieve the appropriate message, extracting the key for the hash enty from the signal emitting widget name. +To identify the menu item's description status messages in our 'create_popup_menu' and finally in the callback 'statusbar_hint' method, we had to do some preparation work at the time when menu items were created. First we assigned the name to all our menu items by calling Gtk::Widget#name= on these objects. We use this name in two places: (1) first in 'create_popup_menu' method where we store status messages in a hash by using menu item's name as the key, and (2) in the callback - signal handler method (statusbar_hint), where we use this hash to retrieve the appropriate message, extracting the key for the hash enty from the signal emitting widget name.