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

アーカイブの一覧に戻る

ruby-****@sourc***** ruby-****@sourc*****
2012年 10月 25日 (木) 05:27:53 JST


-------------------------
REMOTE_ADDR = 184.145.49.94
REMOTE_HOST = 
        URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-popup
-------------------------
@@ -250,9 +250,27 @@
  Gtk.main
 
 
-To create this example program we have used the previous "popupmenus.rb" program, beside a trivial change  in it's name label, the only important difference can be found in the ((*create_popup_menu*)) method. There are quite a few things there that require our attention. First is the creation of the accelerator group Gtk::AccelGroup object. That is the object in which keyboard accelerators are stored. In order to implement accelerators in your application you need to create a new accelerator group. This group must be added to the Gtk::Window, where the menu will appear for it to take effect. It must also be associated with any menus that will take advantage of its accelerators. After the creation of accelerator group instance, the rest of what was just mentioned is accomplished with Gtk::Window#add_accel_group(group) and Gtk::MenuItem#accel_group=(group). But the most involved is the method Gtk::Widget#add_accelerator. You can better understand its many parameters by reading
  the API segment that describes it:
+To create this example program we have used the previous "popupmenus.rb" program, beside a trivial change  in it's name label, the only important difference can be found in the ((*create_popup_menu*)) method. There are quite a few things there that require our attention. First is the creation of the accelerator group Gtk::AccelGroup object. That is the object in which keyboard accelerators are stored. In order to implement accelerators in your application you need to create a new accelerator group. This group must be added to the Gtk::Window, where the menu will appear for it to be able to respond to the accelerator key presses when the window widget has the focus. Accelerator group must also be associated with any menus that will take advantage of its accelerators, this is accomplished with Gtk::Menu#accel_group=(accel_group) and Gtk::Widget#add_accelerator. 
 
+  # Create a keyboard accelerator group for the application.
+  group = Gtk::AccelGroup.new
+  window.add_accel_group(group)
+  ## menu.accel_group=(group)     ## Despite what is said in API, this line is not really required here
+  
+  # Add the necessary keyboard accelerators.
+  # Widget#add_accelerator(accel_signal='activate', group, accel_key, accel_mods, accel_flags)
+  pulse.add_accelerator('activate', group, Gdk::Keyval::GDK_P,
+        Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE)
+  fill.add_accelerator('activate', group, Gdk::Keyval::GDK_F,
+        Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE)
+  clear.add_accelerator('activate', group, Gdk::Keyval::GDK_C,
+        Gdk::Window::CONTROL_MASK|Gdk::Window::SHIFT_MASK, Gtk::ACCEL_VISIBLE)
 
+To add an accelerator to a widget, you can use Gtk::Widget#add_accelerator method, which will emit the signal specified by the ((*"accel_signal='activate'"*)) parameter on the widget, when the user presses the key combination. Indeed for this to work, the accelerator group must be associated with the window and the menu items as mentioned earlier. The modifiers  are specified in (((<GdkModifierType|Gdk::Window#GdkModifierType>))). Most often used modifiers are Gdk::Window::SHIFT_MASK, Gdk::Window::CONTROL_MASK, and Gdk::Window::MOD1_MASK, which correspond to Shift, Ctrl, and Alt keys respectively. The last parameter accel_flags (Gtk::ACCEL_VISIBLE) will make the accelerator visible in the label, Gtk::ACCEL_LOCKED will prevent the user from modifying the accelerator, Gtk::ACCEL_MASK will set both flags for the widget accelerator.
+
+For your convenience following is the Gtk::Widget#add_accelerator API documentation. You can better understand its many parameters by reading the API segment that describes it:
+
+
 --- add_accelerator(accel_signal, accel_group, accel_key, accel_mods, accel_flags)
 
     Installs an accelerator for this widget in accel_group that causes accel_signal to be emitted if the accelerator is activated. The accel_group needs to be added to the widget's toplevel via Gtk::Window#add_accel_group. Accelerators added through this function are not user changeable during run-time. If you want to support accelerators that can be changed by the user, use Gtk::AccelMap#add_entry and Gtk::Widget#set_accel_path or Gtk::MenuItem#accel_path= instead.
@@ -262,7 +280,25 @@
     * accel_mods: modifier key combination of the accelerator(((<GdkModifierType|Gdk::Window#GdkModifierType>)))
     * accel_flags: flag accelerators(((<GtkAccelFlags|Gtk#GtkAccelFlags>))), e.g. Gtk::ACCEL_VISIBLE
     * Returns: self
+
 
-To add an accelerator to a widget, you can use Gtk::Widget#add_accelerator method, which will emit the signal specified by the "accel_signal" parameter on the widget, when the user presses the key combination. Indeed for this to work, the accelerator group must be associated with the window and the menu items as mentioned earlier. The modifiers  are specified in (((<GdkModifierType|Gdk::Window#GdkModifierType>))). Most often used modifiers are Gdk::Window::SHIFT_MASK, Gdk::Window::CONTROL_MASK, and Gdk::Window::MOD1_MASK, which correspond to Shift, Ctrl, and Alt keys respectively. The last parameter accel_flags (Gtk::ACCEL_VISIBLE) will make the accelerator visible in the label, Gtk::ACCEL_LOCKED will prevent the user from modifying the accelerator, Gtk::ACCEL_MASK will set both flags for the widget accelerator.
 
-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.
+It is possible to manually create keyboard accelerators with Gtk::AccelMap, but in most cases the Gtk::Widget#add_accelerator#add_accelerator will provide all the necessary functionality.




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