ruby-****@sourc*****
ruby-****@sourc*****
2012年 11月 10日 (土) 04:02:46 JST
------------------------- REMOTE_ADDR = 184.145.95.170 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-mnstbs-mnub ------------------------- @@ -77,8 +77,8 @@ # Create Language sub menu langmenu = Gtk::Menu.new -# Add '<Ctrl>+L' accelerator to Gtk::AccelGroup object, and -# set the callback to open the Languages context menu. + # Add '<Ctrl>+L' accelerator to Gtk::AccelGroup object, and + # set the callback to open the Languages context menu. group.connect(Gdk::Keyval::GDK_L, Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE) do puts "You've Pressed 'L'." langmenu.popup(nil, nil, 0, Gdk::Event::CURRENT_TIME) @@ -201,8 +201,8 @@ You can see the result of this action on the image here on the left. Note that the Language menu, here shown as the context menu spawned from the main window with accelerator keys '<ctrl>+L', is actually a sub-menu on Organize menu (here on the right). To accomplish this we have to connect a menu-popup spawning callback to the desired accelerator key combination. We accomplish this by calling Gtk::AccelGroup#connect(accel_key, accel_mods, accel_flags) {...} method on the Gtk::AccelGroup object we created earlier: -# Add '<Ctrl>+L' accelerator to Gtk::AccelGroup object, and -# set the callback to open the Languages context menu. + # Add '<Ctrl>+L' accelerator to Gtk::AccelGroup object, and + # set the callback to open the Languages context menu. group.connect(Gdk::Keyval::GDK_L, Gdk::Window::CONTROL_MASK, Gtk::ACCEL_VISIBLE) do puts "You've Pressed 'L'." langmenu.popup(nil, nil, 0, Gdk::Event::CURRENT_TIME)