From 80726824d6f7fd5c82a1507c410b3b2fe0820e86 Mon Sep 17 00:00:00 2001 From: Lakshmi Shanmugam Date: Wed, 28 Aug 2019 17:14:55 +0530 Subject: Bug 383750 - [Cocoa] Focus transfer copies values into text fields Don't call super in Text.becomeFirstResponder for SINGLE style Text widget. This causes multiple focus change events and results in unwanted chang to the text set in the text field. Change-Id: I7f3db189b2f6c8315950b970bcc89bf6c7d357d8 --- .../cocoa/org/eclipse/swt/widgets/Text.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java index 7014f7114b..98db43d16e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java @@ -347,10 +347,11 @@ public void append (String string) { @Override boolean becomeFirstResponder (long id, long sel) { - receivingFocus = true; - boolean result = super.becomeFirstResponder (id, sel); - receivingFocus = false; - return result; + if ((style & SWT.SINGLE) != 0) { + if ((state & DISABLED) != 0) return false; + return true; + } + return super.becomeFirstResponder (id, sel); } static int checkStyle (int style) { @@ -820,6 +821,15 @@ Cursor findCursor () { return (cursor != null) ? cursor : display.getSystemCursor (SWT.CURSOR_IBEAM); } +@Override +boolean forceFocus(NSView focusView) { + receivingFocus = true; + boolean result = super.forceFocus(focusView); + if (((style & SWT.SINGLE) != 0)) ((NSTextField) view).selectText(null); + receivingFocus = false; + return result; +} + /** * Returns the line number of the caret. *

-- cgit v1.2.3