[Gtk-osx-users] StatusIcon, popup menu does not get focus


My app uses a popdown menu from a StatusIcon, it does not necessarily
have any windows of its own shown on screen.

The problem is that the popdown menu shown ('popup-menu' signal on the
StatusIcon) will react to mouse clicks correctly if the app was already
focused, but not if another app was in the foreground and the user
clicks on the StatusIcon ('activate' signal). It then takes a long click
to get the menu to register it (as the app has to gain focus).

Is there a way I can force my application to gain focus when the
StatusIcon is clicked on? Or another workaround?

Simple example application attached (add a 'tray.png' icon of your
choosing). Run it, then try to interact with the menu hanging of it.

import gtk

def quit(*args):

menu = gtk.Menu()
menu.add(gtk.MenuItem("Item 1"))
quit_item = gtk.MenuItem("Quit")
quit_item.connect("activate", quit)

tray_widget = gtk.status_icon_new_from_file("./tray.png")
tray_widget.set_tooltip("hello tooltip")

def popup_menu(widget, button, time, *args):
	menu.popup(None, None, None, button, time, tray_widget)

def activate_menu(*args):
	print "activate_menu(%s)" % str(args)

tray_widget.connect('popup-menu', popup_menu)
tray_widget.connect('activate', activate_menu)


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