Re: signal for an image




On May 17, 2006, at 8:39 PM, David lacravate wrote:

Hi ,

En ce jour du Wed, 17 May 2006 19:00:40 +0100,
Emmanuele Bassi <ebassi gmail com> parlait ainsi :
i have a seemingly simple question . I'd like to click on an image
(Gtk2::Image presumably) and have something happening (another image
appearing) .
Put the Gtk2::Image inside a Gtk2::EventBox and connect to its
'button-press-signal'; you might need to use Gtk2::Widget::add_events on
the event box, to add the 'button-press-mask'.

Sorry , 'doesn't work !

...

$event->signal_connect('clicked',sub{print "ok\n";});

"clicked" is a GtkButton signal, which aggregates the "button-press- event" and "button-release-event" signals. The "clicked" signal does not exist in Gtk2::Widget or Gtk2::EventBox.

To catch a mouse button press, connect to "button-press-event". To catch a mouse button release, connect to "button-release-event" (will require that you add "button-release-mask" to the EventBox's events).

The available signals for each widget are listed in the SIGNALS section of each object's manpage; signals are inherited, so also be sure to check the SIGNALS section of each class mentioned in the HIERARCHY section of the manpage. For example, Gtk2::EventBox has no signals of its own; nor do Gtk2::Bin or Gtk2::Container; but they inherit a whole shedload of signals from Gtk2::Widget.

--
"the ternary operator makes it a bit less ugly."
    -- kaffee




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