ruby-****@sourc*****
ruby-****@sourc*****
2012年 11月 7日 (水) 04:28:54 JST
------------------------- REMOTE_ADDR = 184.145.95.170 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-mnub ------------------------- @@ -180,9 +180,8 @@ #(9.5.1) === Adding Keyboard Accelerators To Menu Items +If you look at the images in this section or run the example program and check out the contents of the menus, you will notice that some menu items include keyboard accelerator key combinations. You will also realize that, we did not 'hard-code' these strings into menu item labels. They just magically appear on our menus. Well, not magically, we actually made them appear by creating Gtk::AccelGroup object and passing it as the parameter to the constructor of those menu items that need it (Gtk::ImageMenuItem.new(stock_id, accel_group), or if a particular menu item constructor does not accept 'accel_group' parameter add it to that menu item after it is created by calling the inherited Gtk::Widget#add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags) method on it. -If you look at the images in this section or run the example program and check out the contents of the menus, you will notice that some menu items include keyboard accelerator key combinations. You will also realize that, we did not 'hard-code' these strings into menu item labels. They just magically appear on our menus. Well, not magically, we actually made them appear by creating Gtk::AccelGroup object and passing it as the parameter to the constructor of those menu items that need it (Gtk::ImageMenuItem.new(stock_id, accel_group), or if a particular menu item constructor does not accept 'accel_group' parameter add it to that menu item after it is created by calling the inherited Widget::add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags) method on it. - {{br}} @@ -208,4 +207,3 @@ :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 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 full treatment of accelerator path see 9.2.1 '((<Accelerator Path|tut-gtk2-mnstbs-popup#Accelerator Path>))'