Re: pop menu with a right-click in a gtktreeview
- From: Kevin Ryde <user42 zip com au>
- To: gtk-perl-list gnome org
- Subject: Re: pop menu with a right-click in a gtktreeview
- Date: Thu, 26 Jun 2008 08:45:45 +1000
"muppet" <scott asofyet org> writes:
gtk_menu_popup() consumes the menu widget (that is, calls destroy on it) for
itself. Click in this window and watch when the lolcat complains on stdout:
Are you sure that's not just the last reference being lost for a local
variable? A global like below seems ok.
I don't know enough glade to guess which way it happens there.
I thought glade created everything at startup, and then hung onto it
forever, if you know what I mean.
#!/usr/bin/perl
use strict;
use warnings;
use Gtk2 -init;
my $window = Gtk2::Window->new;
$window->add_events (['button-press-mask', 'button-release-mask']);
$window->signal_connect (button_release_event => \&do_menu);
$window->signal_connect (destroy => sub { Gtk2->main_quit });
$window->show;
Gtk2->main;
my $menu;
sub do_menu {
my ($widget, $event) = @_;
$menu ||= do {
my $menu = Gtk2::Menu->new;
$menu->signal_connect (destroy => sub {
print "halp, i'z bein destroyeded!\n";
return 0;
});
my $item = Gtk2::MenuItem->new ("Cheezburger");
$menu->append ($item);
$item->show;
$menu
};
$menu->popup (undef, undef, undef, undef, $event->button, $event->time);
return 0;
}
--
Blessed are the cheesemakers
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]