[ruby-gnome2-doc-cvs] [Ruby-GNOME2 Project Website] update - tut-gtk2-mnstbs-mnub

アーカイブの一覧に戻る

ruby-****@sourc***** ruby-****@sourc*****
2012年 11月 7日 (水) 05:34:29 JST


-------------------------
REMOTE_ADDR = 184.145.95.170
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-mnub
-------------------------
@@ -207,4 +207,27 @@
 
 :Using Accelerator Path In Menus
 
-    Unfortunately building accelerator path with Gtk::AccelMap.add_entry does not bring anything valuable to the menu designs. Creating 'accel-path' and adding it to the Gtk::AccelGroup seems redundant and incompletely implemented in Gtk. In particular mi.accel_path = "my-acc-p/xyz" has no effect, and fails to display the accelerator key on the menu item! The only thing that works is that callback is called when accelerator key is pressed. With the exception of the additional control the accelerator key callback provides to react differently in this callback only when the accelerator keys were pressed, you can accomplish everything by calling the inherited Gtk::Widget#add_accelerator method on menu item objects. For full treatment of accelerator path see 9.2.1 '((<Accelerator Path|tut-gtk2-mnstbs-popup#Accelerator Path>))'
+    Unfortunately building accelerator path with Gtk::AccelMap.add_entry does not bring anything valuable to the menu designs. Creating 'accel-path' and adding it to the Gtk::AccelGroup seems redundant and incompletely implemented in Gtk. In particular mi.accel_path = "my-acc-p/xyz" has no effect, and fails to display the accelerator key on the menu item! The only thing that works is that callback is called when accelerator key is pressed. With the exception of the additional control the accelerator key callback provides to react differently in this callback only when the accelerator keys were pressed, you can accomplish everything by calling the inherited Gtk::Widget#add_accelerator method on menu item objects.
+
+    For instance, if we wish to create new accelerator path((*'<Menu Bar w/submenus (1)>/Organize/Preferences'*)) for our Preferences menu item for the Organize toolbar option, we could do the following: 
+
+     # Gtk::AccelMap.add_entry(accel_path, accel_key, accel_mods)
+     Gtk::AccelMap.add_entry("<Menu Bar w/submenus (1)>/Organize/Preferences",
+          Gdk::Keyval::GDK_P, Gdk::Window::MOD1_MASK)
+     group.connect("<Menu Bar w/submenus (1)>/Organize/Preferences") {
+       puts "You've pressed <Alt+P> and, therefore, selected Preferences."
+     }
+     # . . .
+     # Create Organize submenu
+     preferences = Gtk::MenuItem.new("Preferences")
+     preferences.signal_connect('activate') { |w| puts "w=#{w.class}:Preferences selected" }
+     preferences.accel_path = "<Menu Bar w/submenus (1)>/Organize/Preferences"  ### Not needed
+
+    The '<Alt+P>' accelerator key press works, however, the this key combination does not appear on the menu item, even though, we run the((*'preferences.accel_path='*))statement, which most likely is a flag telling Gtk menu system to place accelerators mapped to this accelerator path on the receiver menu item object. Unless you need an extra callback method to be called only when accelerator keys are pressed, you really do not need to go through the trouble creating accelerator paths. You can accomplish everything by installing the accelerators only using Gtk::Widget#add_accelerator method:
+
+     preferences.add_accelerator('activate', group, Gdk::Keyval::GDK_P,
+        Gdk::Window::MOD1_MASK, Gtk::ACCEL_VISIBLE)
+
+    This would also display the accelerator keys on the Preferences menu item. Note if you install both the accelerator path as well as the 'activate' signal with the above 'add_accelerator' method, both callbacks are called when you use the accelerator keys, but only signal-handler's callback is called if you use mouse to select the Preference menu item on the menu.
+
+    For full treatment of accelerator path see 9.2.1 '((<Accelerator Path|tut-gtk2-mnstbs-popup#Accelerator Path>))'




ruby-gnome2-cvs メーリングリストの案内
アーカイブの一覧に戻る