Re: button_press_event from image




On Oct 10, 2006, at 3:59 AM, Ratcliffe, Jeffrey (Peters) wrote:

you must pack the Gtk2::Image inside a Gtk2::EventBox, as the image
widget does not listen to the button events.

Thanks. It works a treat now.

Why does the Gtk2::Image not inherit the signals from Gtk2::Widget - amongst them button_press_event?

GtkImage, like GtkLabel, is used primarily to display pixels. Nine times out of ten, you just show and image, without needing it to respond to events, or wanting its parent to respond to events (e.g. when packed into a button). So, GtkImage does not have a GdkWindow of its own (a.k.a. a "NO_WINDOW" widget). This saves server resources and makes the event handling in your app simpler in the common case. Widgets without a GdkWindow cannot receive input events. So, if you want a GtkImage to accept input events, you have to pack it into a GtkEventBox, which is essentially a GtkWidget whose sole purpose is to have a GdkWindow.


--
Brian: If i recall correctly, this is the physics department.
Chris: That explains all that gravity.
    -- Family Guy, "The Story on Page One"




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]