button_press_event from image



I'm trying to make the right mouse button useful in an application. In the demo code below, the image doesn't 
respond to any button_press_event. What am I doing wrong?

Jeff

#!/usr/bin/perl

use warnings;
use strict;
use Gtk2 -init;
use Glib qw(TRUE FALSE);

my $window = Gtk2::Window -> new;
$window -> signal_connect ( destroy => sub { Gtk2 -> main_quit; } );
my $vbox = new Gtk2::VBox ( FALSE, 1 );
$window -> add ( $vbox );
my $image = Gtk2::Image->new_from_stock ('gtk-delete', 'dialog');
$image->signal_connect(button_press_event => \&handle_clicks);
$vbox -> pack_start ($image, FALSE, FALSE, 0);

$window -> show_all;
Gtk2 -> main;

sub handle_clicks {
 my ($check, $event) = @_;
warn "pressed\n";

 if (3 eq $event->button) {
warn "right click pressed\n";
 }
 return 0;
}



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