Gtk::StatusIcon menu popup on activate and current_time

Hi everyone,

I’m trying to popup a menu on a StatusIcon on a left mouse click,
however the menu will immediately disappear after the click unless the
mouse button is held down.

Apparently this has to do with the current_time parameter of the
Menu::popup function.
Since the StatusIcon activate signal doesn’t pass activate_time I have
to give the popup function a 0, that causes the menu to close
immediately.

Is there another way to get the activate_time?
Gdk::Event::CURRENT_TIME gives me 0. Or is there another way to make
the menu stay open?

Thanks,
Rafaël

Use Gtk.current_event_time

best,
Dan


Daniel L.
http://www.daniellucraft.com/

2008/12/6 Rafaël Bekkema [email protected]:

I haven’t tried the StatusIcon but here is how my action handlers create
a popup:

def on_action()
create_menu_popup(get_item_names()) do |widget, event|
on_menu_activate(widget)
end
end

def create_menu_popup(item_names, &block)
menu = Gtk::Menu.new
item_names.each do |name|
menu_item = Gtk::MenuItem.new(name)
menu_item.signal_connect(‘button-press-event’, block)
menu.append(menu_item)
end
menu.show_all
event = Gdk::EventButton.new(Gdk::Event::BUTTON_PRESS)
menu.popup(nil, nil, event.button, event.time)
end

This works fine on menus and toolbars.

HTH,
Roy

Thank you,
Rafaël
2008/12/7 Daniel L. [email protected]: