Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 350341 - Left click on TrayItem aligns Menu pop up to mouse cursor instead of icon on Mac OS X
Summary: Left click on TrayItem aligns Menu pop up to mouse cursor instead of icon on ...
Status: CLOSED WORKSFORME
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.1   Edit
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-24 21:34 EDT by Dennis Ju CLA
Modified: 2012-08-03 09:24 EDT (History)
1 user (show)

See Also:


Attachments
Image of issue. (81.83 KB, image/png)
2011-06-24 21:48 EDT, Dennis Ju CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.