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.
Rafaël Bekkema (Guest)
on 2008-12-06 16: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
Daniel L. (Guest)
on 2008-12-07 10:19
(Received via mailing list)
Use Gtk.current_event_time

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



2008/12/6 Rafaël Bekkema <removed_email_address@domain.invalid>:
Roy W. (Guest)
on 2008-12-07 12: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
Rafaël Bekkema (Guest)
on 2008-12-07 14:02
(Received via mailing list)
Thank you,
Rafaël
2008/12/7 Daniel L. <removed_email_address@domain.invalid>:
This topic is locked and can not be replied to.