popup menus?



I've been banging my head against a wall all day, so perhaps its time to
turn to the list...

How does one create a popup menu? I've created an itemfactory as
follows:

    my $ag = Gtk2::AccelGroup->new();
    my $item_fac = Gtk2::ItemFactory->new('Gtk2::Menu', '<menu>', $ag);
    my @menu_items = (
        ["/Home", undef, undef, 0],
        ["/Test", undef, undef, 0],
        ["/Last", undef, undef, 0],
    );
    $item_fac->create_items(undef, @menu_items);
    my $menu = $item_fac->get_widget('<menu>');
    my $menu_button = Gtk2::Button->new('<');
    
    $menu_button->signal_connect('clicked' => sub {
            $menu->popup();
        }
    );

But this doesn't work. I'm guessing a couple of things are wrong, but
I'm not sure how to correct them:

    (1) I'm not sure an ItemFactory is the way to go -- I'm not certain
        that I'm creating the menu items correctly (which I want to be
        listed vertically).
    (2) I'm not certain the correct way to cause the menu to popup. The
        Gtk2 specs indicate I need to tell menu.popup the button that
        caused it to raise and the timestamp. I don't know where to get
        these. 

I've also tried placing the menu in a popup window, but the menu didn't
show. Can anyone shed some light on this?

-- 
Matthew Weier O'Phinney
http://weierophinney.net/matthew/



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