ruby-****@sourc*****
ruby-****@sourc*****
2012年 8月 26日 (日) 03:20:16 JST
------------------------- REMOTE_ADDR = 70.49.49.99 REMOTE_HOST = URL = http://ruby-gnome2.sourceforge.jp/hiki.cgi?tut-gtk2-contwidg-eventbox ------------------------- @@ -9,7 +9,7 @@ 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. +You must call Gtk::Widget#set_events before you call Gtk::Widget#realize on the widget (eg.: eventbox.realize). However, if the widget (eventbox) 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. When you realize your event box, you have to make sure that it is already added as a child to a top-level widget, or it will not work. This is because, when you realize a widget, it will automatically realize its ancestors. If it has no ancestors, GTK+ will not be happy and realization will fail.