On mac, how to detect mouse right click on taskbaricon of wxpython application

673 Views Asked by At

I have running simple wxpython application reside in Taskbar/System-tray area that shows popup menu when user click on it. Work fine except I need to show popup menu when user click right mouse button on Taskbar icon (mac).

Binding right click like:

self.Bind(wx.EVT_TASKBAR_RIGHT_UP, self.onRight) 

do not do anything.

2

There are 2 best solutions below

2
On

You don't need to bind the event directly. The wx.TaskBarIcon has a method to add a right-click menu, although the wxPython docs are a bit light-on, the wxWigets docs explain it quite well.

If the C++ docs confuse you, have a look at the excellent Mouse vs Python tutorial on taskbar icons.

ETA:

Note that by default wxPython gives you the wxWigets menubar item on Mac, which as far as I can tell, only captures a left-click event (line 353). You can get a dock taskbar item if you construct your item passing the right magic words:

wx.TaskBarIcon(wx.TBI_DOCK)

This can capture left and right clicks.

0
On

This is known issue of wxwidget 2.9.4 in which event is not triggered when taskbaricon is right clicked. http://trac.wxwidgets.org/ticket/14646