Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 350341

Summary: Left click on TrayItem aligns Menu pop up to mouse cursor instead of icon on Mac OS X
Product: [Eclipse Project] Platform Reporter: Dennis Ju <dejuknow>
Component: SWTAssignee: Platform-SWT-Inbox <platform-swt-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: normal    
Priority: P3 CC: lshanmug
Version: 4.1   
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X   
Whiteboard:
Attachments:
Description Flags
Image of issue. none

Description Dennis Ju CLA 2011-06-24 21:34:06 EDT
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.
Comment 1 Dennis Ju CLA 2011-06-24 21:48:12 EDT
Created attachment 198593 [details]
Image of issue.
Comment 2 Lakshmi P Shanmugam CLA 2011-06-27 04:34:44 EDT
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.
Comment 3 Lakshmi P Shanmugam CLA 2012-08-03 09:24:44 EDT
Closing as worksforme, please reopen if solution in comment #2 doesn't work for you.