Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLakshmi Shanmugam2019-08-28 11:44:55 +0000
committerLakshmi Shanmugam2019-09-04 09:18:18 +0000
commit80726824d6f7fd5c82a1507c410b3b2fe0820e86 (patch)
tree04260641c578a4e2d8859e44df85cf5848219587
parent7f7383116d8c3507b1397c68d1867f820d75a74d (diff)
downloadeclipse.platform.swt-80726824d6f7fd5c82a1507c410b3b2fe0820e86.tar.gz
eclipse.platform.swt-80726824d6f7fd5c82a1507c410b3b2fe0820e86.tar.xz
eclipse.platform.swt-80726824d6f7fd5c82a1507c410b3b2fe0820e86.zip
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
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java18
1 files 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.
* <p>

Back to the top