ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 26日 (日) 03:13:59 JST
------------------------- REMOTE_ADDR = 70.49.49.99 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-contwidg-eventbox ------------------------- @@ -7,7 +7,7 @@ Various widgets including Gtk::Label do not respond to GDK events, because they do not have an associated Gdk::Window. To fix this GTK+ employs a Gtk::EventBox container widget. The Gtk::EventBox provides a capability that allows its child, otherwise incapable of catching GDK events, to intercept or catch them. Gtk::EventBox does that on behalf of the child. Note these are GDK and not GTK signals! -Event boxes catch events for the children widgets by providing a Gdk::Window for the object. Setting up a GDK event/signal catching mechanism, unlike in C GTK+, in Ruby does not use the usual "signal_connect" syntax. It suffices to setup events with the Gtk::Window#events= or Gtk::Window#set_events, by adding an event mask to the event box (see GdkEventMask below). +Event boxes catch events for the children widgets by providing a Gdk::Window for the object. Setting up a GDK event/signal catching mechanism, unlike in C GTK+, in Ruby does not use the usual "signal_connect" syntax. It suffices to setup events with the Gdk::Window#events= or Gdk::Window#set_events (or either Gtk::Widget#events= or Gtk::Widget#set_events) , by adding an event mask to the event box (see GdkEventMask below). You must call Gtk::Widget#set_events before you call Gtk::Widget#realize on the widget. However, if the widget has already been realized by GTK+, you will need to instead use the Gtk::Widget#add_events to add the event mask. Before calling Gtk::Widget#realize, your event box (eventbox = Gtk::EventBox.new), does not have the Gdk::Window and/or any other GDK widget resources associated with it. Normally, realization occurs when the parent is realized, but event boxes are an exception. When you call Gtk::Window#show_all on a widget, it is automatically realized by GTK+, but event boxes can not be realized at this point, because they are still invisible. Calling Gtk::Widget#realize on the event box is an easy way around this problem.