Community
Participate
Working Groups
Build Identifier: 20110218-0911 On Mac OS X, left clicking on a TrayItem will cause a menu pop-up to show up aligned to the mouse pointer instead of the TrayItem icon. Right clicking will render the menu properly (with the icon highlighted as expected). Most OS X tray icons will pop up the menu aligned to the icon with both left and right click. The following code will show the difference between the two: //handles left click trayItem.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { menu.setVisible(true); } }); //handles right click trayItem.addListener(SWT.MenuDetect, new Listener() { public void handleEvent(Event event) { menu.setVisible(true); } }); Reproducible: Always Steps to Reproduce: 1. Add the two listeners using the code in the details. 2. Observe the difference between left and right-clicking the TrayItem icon.
Created attachment 198593 [details] Image of issue.
The SWT.MenuDetect Listener itself can be used to handle both right click and left click, if the SWT.Selection (and SWT.DefaultSelection) listener is not added to the trayItem. In the example, remove the code that handles that adds the Selection listener. Then, SWT.MenuDetect event is sent for both left and right click and the menu pops-up correclty.
Closing as worksforme, please reopen if solution in comment #2 doesn't work for you.