Re: pop menu with a right-click in a gtktreeview




anguila wrote:
create a fresh? destroy an create again the widget?

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:


#!/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;

sub do_menu {
    my ($widget, $event) = @_;

    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->popup (undef, undef, undef, undef, $event->button, $event->time);

    # $menu will be destroyed when the user quits interacting with it.

    return 0;
}

__END__

-- 
muppet <scott at asofyet dot org>




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