Forum: Ruby-Gnome 2 Gtk::StatusIcon menu popup on activate and current_time

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E2a2425a61569faa0eb73a28b4830b24?d=identicon&s=25 Rafaël Bekkema (Guest)
on 2008-12-06 15:51
(Received via mailing list)
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
0158871402c1ecfa57952e8a379cfd10?d=identicon&s=25 Daniel Lucraft (lucraft)
on 2008-12-07 09:19
(Received via mailing list)
Use Gtk.current_event_time

best,
Dan
___________________________
Daniel Lucraft
http://www.daniellucraft.com/



2008/12/6 Rafaël Bekkema <rl.bekkema@gmail.com>:
07aaa2c67e8b41fa38f628356a2b163a?d=identicon&s=25 Roy Wright (royw)
on 2008-12-07 11:17
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
E2a2425a61569faa0eb73a28b4830b24?d=identicon&s=25 Rafaël Bekkema (Guest)
on 2008-12-07 13:02
(Received via mailing list)
Thank you,
Rafaël
2008/12/7 Daniel Lucraft <dan@fluentradical.com>:
This topic is locked and can not be replied to.