From 29deb6dad3bbc4a1894b93123ec8c8c5440fbecd Mon Sep 17 00:00:00 2001 From: Silenio Quarti Date: Thu, 4 Oct 2012 17:33:45 -0400 Subject: Bug 388574 - [Mac OS X 10.8] Text control loses focus upon its movement --- .../Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java | 8 ++++++++ .../Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java | 2 ++ 2 files changed, 10 insertions(+) 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 dded880d88..6e045352bf 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 @@ -3526,6 +3526,13 @@ public void setBounds (int x, int y, int width, int height) { } void setBounds (int x, int y, int width, int height, boolean move, boolean resize) { + /* + * Bug in Cocoa. On Mac 10.8, a text control loses and gains focus + * when its bounds changes. The fix is to ignore these events. + */ + Display display = this.display; + boolean oldIgnoreFocus = display.ignoreFocus; + display.ignoreFocus = true; NSView topView = topView(); if (move && resize) { NSRect rect = new NSRect(); @@ -3545,6 +3552,7 @@ void setBounds (int x, int y, int width, int height, boolean move, boolean resiz size.height = height; topView.setFrameSize(size); } + display.ignoreFocus = oldIgnoreFocus; } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java index f4558aab5f..7706c173b9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java @@ -126,6 +126,7 @@ public class Display extends Device { Caret currentCaret; + boolean ignoreFocus; boolean sendEvent; int clickCountButton, clickCount; int blinkTime; @@ -643,6 +644,7 @@ void checkEnterExit (Control control, NSEvent nsEvent, boolean send) { } void checkFocus () { + if (ignoreFocus) return; Control oldControl = currentFocusControl; Control newControl = getFocusControl (); if (oldControl != newControl) { -- cgit