diff options
author | Till Brychcy | 2018-02-19 21:30:47 +0000 |
---|---|---|
committer | Lakshmi Shanmugam | 2018-03-02 12:07:24 +0000 |
commit | e385fcbbec9141cfa9f82f55c4d03c505943c11e (patch) | |
tree | 9321d76002c64b5b479fb8393d473e8c1a6a8f43 | |
parent | 8a06388fe326804fa333f0460626bcea60fbf2d9 (diff) | |
download | eclipse.platform.swt-e385fcbbec9141cfa9f82f55c4d03c505943c11e.tar.gz eclipse.platform.swt-e385fcbbec9141cfa9f82f55c4d03c505943c11e.tar.xz eclipse.platform.swt-e385fcbbec9141cfa9f82f55c4d03c505943c11e.zip |
Bug 378202 - Two-finger tap to simulate right-click results in
multiple click events
Control.menuForEvent needs to return the menu to be shown for the right
click instead of 0, or the right click will be propagated up the chain.
If the menu is result of getMenu(), it is returned.
If it is created in the SWT.MenuDetect event listener, it is not shown
yet, but registered in display.popups. When this is detected it is
removed from that array and returned.
Change-Id: Ia2bf133f61b0ce74d036c9188fbf1dd36ca76508
Signed-off-by: Till Brychcy <register.eclipse@brychcy.de>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java index 60fcfc867c..f2a5050d0d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java @@ -2502,18 +2502,39 @@ long /*int*/ menuForEvent (long /*int*/ id, long /*int*/ sel, long /*int*/ theEv event.y = y; NSEvent nsEvent = new NSEvent(theEvent); event.detail = nsEvent.buttonNumber() > 0 ? SWT.MENU_MOUSE : SWT.MENU_KEYBOARD; - sendEvent (SWT.MenuDetect, event); + + int count = 0; + if (display.popups != null) { + while (count < display.popups.length && display.popups[count] != null) { + count++; + } + } + + sendEvent(SWT.MenuDetect, event); //widget could be disposed at this point if (isDisposed ()) return 0; - if (!event.doit) return 0; Menu menu = getMenu (); - if (menu != null && !menu.isDisposed ()) { + if (event.doit && menu != null && !menu.isDisposed ()) { if (x != event.x || y != event.y) { menu.setLocation (event.x, event.y); } - menu.setVisible(true); - return 0; + return menu.nsMenu.id; + } + + // There is either no popup menu set for the Control or event.doit = false. + // If a popup was triggered in the MenuDetect listener, return it. + int count2 = 0; + if (display.popups != null) { + while (count2 < display.popups.length && display.popups[count2] != null) { + count2++; + } + } + if (count2 != count && count2 > 0) { + Menu menu1 = display.popups[count2 - 1]; + display.popups[count2 - 1] = null; + return menu1.nsMenu.id; } + if (!event.doit) return 0; return super.menuForEvent (id, sel, theEvent); } |