ruby-****@sourc*****
ruby-****@sourc*****
2012年 11月 6日 (火) 11:01:31 JST
------------------------- REMOTE_ADDR = 184.145.95.170 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-popup ------------------------- @@ -342,15 +342,23 @@ -It is possible to manually create keyboard accelerators with Gtk::AccelMap, but in most cases the Gtk::Widget#add_accelerator will provide all the necessary functionality, nevertheless, we will see the AccelMap feature in the following example((*'custom-accelerators.rb'.*)) +=== Accelerator Path +It is possible to manually create keyboard accelerators with Gtk::AccelMap, but in most cases the Gtk::Widget#add_accelerator will provide all the necessary functionality, nevertheless, we will see the AccelMap feature in the following example((*'custom-accelerators.rb'.*)) + + +The accelerator path is a string you create. It must consist of ((*"<WINDOWTYPE>/Category1/Category2/.../Action"*)), where <WINDOWTYPE> should be a unique application-specific identifier, that corresponds to the kind of window the accelerator is being used in, e.g. "Gimp-Image", "Abiword-Document" or "Gnumeric-Settings". The Category1/.../Action portion is most appropriately chosen by the action the accelerator triggers, i.e. for accelerators on menu items, choose the item's menu path, e.g. "File/Save As", "Image/View/Zoom" or "Edit/Select All". So a full valid accelerator path may look like: "<Gimp-Toolbox>/File/Dialogs/Tool Options...". Accelerator path is mapped to accelerator keys and added to the global accelerator map with Gtk::AccelMap.add_entry(accel_path, accel_key, accel_mods). + + + + +:Accelerators can also be used in programs without menus -=== Accelerators can also be used in programs without menus + All accelerators, regardless of whether they are associated with menus or not, use global Gtk::AccelMap object which defines a list entries in this table in the form of mappings between a unique accelerator name (in the Gtk::AccelMap known as the ((*'accel_path')*))and the actual key combinations. These accelerators (keys) or 'accel_paths' eventually have to be mapped to actions. There however, is a difference how actions are associated with menu item accelerators in windows with menus and in windows without menus, i.e. for windows themselves. First you will notice that in either case we use Gtk::Window#add_accel_group(group). Note, that this statement is mandatory only in the programs without menus, but should be included in programs with menus only when in addition to triggering actions through menu items you also wish to provide the access to this functionality via accelerator keys. The other more pronounced difference is how actions are associated either with menu it ems, or merely with the accelerator abstractions, as is the case in programs without the menus. While for menu items their respective actions are triggered by a specified signal (remember the((*"accel_signal='activate'"*)) parameter to the Gtk::Widget#add_accelerator method above), in programs without menus accelerator key actions are associated directly to the corresponding accelerator key abstractions (e.g.: 'accel_key,...' and 'accel_path'). This is accomplished with the help of 'Gtk::AccelGroup#connect(accel_key, accel_mods, accel_flags, closure)', 'Gtk::AccelGroup#connect(accel_key, accel_mods, accel_flags) {...}', or 'Gtk::AccelGroup#connect(accel_path, closure)', or 'Gtk::AccelGroup#connect(accel_path) {...}'. -All accelerators, regardless of whether they are associated with menus or not, use global Gtk::AccelMap object which defines a list entries in this table in the form of mappings between a unique accelerator name (in the Gtk::AccelMap known as the ((*'accel_path')*))and the actual key combinations. These accelerators (keys) or 'accel_paths' eventually have to be mapped to actions. There however, is a difference how actions are associated with menu item accelerators in windows with menus and in windows without menus, i.e. for windows themselves. First you will notice that in either case we use Gtk::Window#add_accel_group(group). Note, that this statement is mandatory only in the programs without menus, but should be included in programs with menus only when in addition to triggering actions through menu items you also wish to provide the access to this functionality via accelerator keys. The other more pronounced difference is how actions are associated either with menu items, or merely with the accelerator abstractions, as is the case in programs without the menus. While for menu items their respective actions are triggered by a specified signal (remember the((*"accel_signal='activate'"*)) parameter to the Gtk::Widget#add_accelerator method above), in programs without menus accelerator key actions are associated directly to the corresponding accelerator key abstractions (e.g.: 'accel_key,...' and 'accel_path'). This is accomplished with the help of 'Gtk::AccelGroup#connect(accel_key, accel_mods, accel_flags, closure)', 'Gtk::AccelGroup#connect(accel_key, accel_mods, accel_flags) {...}', or 'Gtk::AccelGroup#connect(accel_path, closure)', or 'Gtk::AccelGroup#connect(accel_path) {...}'. {{image_right("accelerator-keys-2.png")}}