From e379287ec5e166c277b3a4f8df3f70c1e5720d36 Mon Sep 17 00:00:00 2001 From: Scott Kovatch Date: Mon, 1 Nov 2010 22:06:27 +0000 Subject: 251446 - ignore next mouseUp after clicking on a link. --- .../cocoa/org/eclipse/swt/widgets/Link.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java index 70b021f7d8..171cffc105 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Link.java @@ -45,6 +45,7 @@ public class Link extends Control { int [] mnemonics; NSColor linkColor; int focusIndex; + boolean ignoreNextMouseUp; /** * Constructs a new instance of this class given its parent @@ -123,6 +124,7 @@ boolean textView_clickOnLink_atIndex(int /*long*/ id, int /*long*/ sel, int /*lo } } redrawWidget(view, false); + ignoreNextMouseUp = true; return true; } @@ -341,11 +343,18 @@ public String getText () { return text; } -// This code prevents selection events from firing. -//boolean mouseEvent (int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent, int type) { -// super.mouseEvent (id, sel, theEvent, type); -// return new NSEvent (theEvent).type () != OS.NSLeftMouseDown; -//} +void mouseUp(int /*long*/ id, int /*long*/ sel, int /*long*/ theEvent) { + /* + * Feature in Cocoa: Link click notices are sent on mouseDown, but for some reason, Cocoa + * re-sends the mouseUp that follows the click on a link. Fix is to ignore the next mouseUp + * fired after a link selection. + */ + if (ignoreNextMouseUp) { + ignoreNextMouseUp = false; + return; + } + super.mouseUp(id, sel, theEvent); +} boolean shouldDrawInsertionPoint(int /*long*/ id, int /*long*/ sel) { return false; -- cgit