Handling button presses in Gtk2::Image objects

Posted by willert on Stack Overflow See other posts from Stack Overflow or by willert
Published on 2010-03-21T17:12:25Z Indexed on 2010/03/21 18:51 UTC
Read the original article Hit count: 394

Filed under:
|
|

I've been trying to get an Gtk2::Image object in this perl Gtk2 application to get to react to button presses, but to no avail. The image shows as expected but the button events don't get handled. What am I missing?

  my $img = Gtk2::Image->new_from_file( $file );
  $img->set_property( sensitive => 1 );
  $img->can_focus( 1 );
  $img->set_events([qw/ button-press-mask button-release-mask /]);
  $img->signal_connect(
    'button-press-event' => sub {
      my ( $self, $event ) = @_;
      print STDERR "Coords: ", $event->get_coords;
      return;
    });
  $window->add( $img );
  $window->show_all;

© Stack Overflow or respective owner

Related posts about perl

Related posts about gtk