diff options
author | Grant Gayed <ggayed> | 2008-03-11 19:17:29 +0000 |
---|---|---|
committer | Grant Gayed <ggayed> | 2008-03-11 19:17:29 +0000 |
commit | a144105fcf4ece78f17e22a9d4b102906a7fadde (patch) | |
tree | 16ebf95c7afee4dc714d09b16e49800511530987 /bundles | |
parent | ec55194e3bf8e6968e32edec40f6b78c27c42e7d (diff) | |
download | eclipse.platform.swt-a144105fcf4ece78f17e22a9d4b102906a7fadde.tar.gz eclipse.platform.swt-a144105fcf4ece78f17e22a9d4b102906a7fadde.tar.xz eclipse.platform.swt-a144105fcf4ece78f17e22a9d4b102906a7fadde.zip |
220975
Diffstat (limited to 'bundles')
9 files changed, 72 insertions, 4 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java index 65fa70d9b2..f514ea568b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java @@ -575,6 +575,7 @@ public static final int class_NSPointerArray = objc_getClass("NSPointerArray"); public static final int class_NSURLAuthenticationChallenge = objc_getClass("NSURLAuthenticationChallenge"); public static final int class_NSStatusBar = objc_getClass("NSStatusBar"); public static final int class_NSTextField = objc_getClass("NSTextField"); +public static final int class_NSSecureTextField = objc_getClass("NSSecureTextField"); public static final int class_NSOutputStream = objc_getClass("NSOutputStream"); public static final int class_NSComboBoxCell = objc_getClass("NSComboBoxCell"); public static final int class_NSXMLDTDNode = objc_getClass("NSXMLDTDNode"); diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTSearchField.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTSearchField.java new file mode 100644 index 0000000000..fbf466a7c1 --- /dev/null +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTSearchField.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2008 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.swt.internal.cocoa; + +public class SWTSearchField extends NSSearchField { + + +} diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTTextView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTTextView.java index b45a93db9f..e5e6a2afd8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTTextView.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/SWTTextView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,14 @@ package org.eclipse.swt.internal.cocoa; public class SWTTextView extends NSTextView { +public SWTTextView() { + super(0); +} + +public SWTTextView(int id) { + super(id); +} + public void setTag(int tag) { OS.objc_msgSend(id, OS.sel_setTag_1, tag); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java index 817ceae04f..f1314e22f1 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java @@ -337,6 +337,16 @@ public Point computeSize (int wHint, int hHint, boolean changed) { return new Point (width, height); } +void controlTextDidBeginEditing(int notification) { + if ((style & SWT.READ_ONLY) == 0) { + NSNotification nsNotification = new NSNotification(notification); + NSDictionary userInfo = nsNotification.userInfo(); + id id = userInfo.objectForKey(NSString.stringWith("NSFieldEditor")); + SWTTextView editor = new SWTTextView(id.id); + editor.setTag(jniRef); + } +} + /** * Copies the selected text. * <p> 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 daff773814..01836f9160 100755 --- 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 @@ -1724,6 +1724,7 @@ void initClasses () { OS.class_addMethod(cls, OS.sel_comboBoxSelectionDidChange_1, proc3, "@:@"); OS.class_addMethod(cls, OS.sel_sendSelection, proc2, "@:"); OS.class_addMethod(cls, OS.sel_menuForEvent_1, proc3, "@:@"); + OS.class_addMethod(cls, OS.sel_controlTextDidBeginEditing_1, proc3, "@:@@"); OS.objc_registerClassPair(cls); className = "SWTDatePicker"; @@ -1777,6 +1778,12 @@ void initClasses () { className = "SWTTextField"; cls = OS.objc_allocateClassPair(OS.class_NSTextField, className, 0); OS.class_addMethod(cls, OS.sel_drawRect_1, drawRectProc, "@:i"); + OS.class_addMethod(cls, OS.sel_controlTextDidBeginEditing_1, proc3, "@:@@"); + OS.objc_registerClassPair(cls); + + className = "SWTSearchField"; + cls = OS.objc_allocateClassPair(OS.class_NSSearchField, className, 0); + OS.class_addMethod(cls, OS.sel_controlTextDidBeginEditing_1, proc3, "@:@@"); OS.objc_registerClassPair(cls); className = "SWTWindow"; @@ -3158,6 +3165,8 @@ int windowDelegateProc(int id, int sel, int arg0) { widget.outlineViewSelectionDidChange(arg0); } else if (sel == OS.sel_sendEvent_1) { widget.windowSendEvent(id, arg0); + } else if (sel == OS.sel_controlTextDidBeginEditing_1) { + widget.controlTextDidBeginEditing(arg0); } return 0; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java index 87d5c344c4..0e9427d060 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java @@ -1283,7 +1283,6 @@ int windowWillReturnFieldEditor_toObject(int window, int anObject) { sharedEditor.setDelegate(sharedEditor); sharedEditor.setEditable(true); } - sharedEditor.setTag(tag); return sharedEditor.id; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java index feb62ee6e1..b15903d894 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Spinner.java @@ -219,6 +219,14 @@ public Rectangle computeTrim (int x, int y, int width, int height) { return super.computeTrim(x, y, width, height); } +void controlTextDidBeginEditing(int notification) { + NSNotification nsNotification = new NSNotification(notification); + NSDictionary userInfo = nsNotification.userInfo(); + id id = userInfo.objectForKey(NSString.stringWith("NSFieldEditor")); + SWTTextView editor = new SWTTextView(id.id); + editor.setTag(jniRef); +} + /** * Copies the selected text. * <p> @@ -262,6 +270,7 @@ void createHandle () { textWidget.initWithFrame(new NSRect()); // textWidget.setTarget(widget); textWidget.setTag(jniRef); + textWidget.setDelegate(textWidget); widget.addSubview_(textWidget); widget.addSubview_(buttonWidget); buttonView = buttonWidget; 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 782941e222..2ec771bde0 100755 --- 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 @@ -303,6 +303,17 @@ public Point computeSize (int wHint, int hHint, boolean changed) { return new Point (width, height); } +void controlTextDidBeginEditing(int notification) { + /* NSSecureText uses its own editor instead of the window's shared editor */ + if ((style & (SWT.SINGLE | SWT.PASSWORD)) == SWT.SINGLE) { + NSNotification nsNotification = new NSNotification(notification); + NSDictionary userInfo = nsNotification.userInfo(); + id id = userInfo.objectForKey(NSString.stringWith("NSFieldEditor")); + SWTTextView editor = new SWTTextView(id.id); + editor.setTag(jniRef); + } +} + /** * Copies the selected text. * <p> @@ -329,7 +340,7 @@ void createHandle () { if ((style & SWT.PASSWORD) != 0) { widget = (NSTextField)new NSSecureTextField().alloc(); } else if ((style & SWT.SEARCH) != 0) { - widget = (NSTextField)new NSSearchField().alloc(); + widget = (NSTextField)new SWTSearchField().alloc(); } else { widget = (NSTextField)new SWTTextField().alloc(); } @@ -341,6 +352,7 @@ void createHandle () { if ((style & SWT.CENTER) != 0) align = OS.NSCenterTextAlignment; if ((style & SWT.RIGHT) != 0) align = OS.NSRightTextAlignment; widget.setAlignment(align); + widget.setDelegate(widget); // widget.setTarget(widget); // widget.setAction(OS.sel_sendSelection); widget.setTag(jniRef); @@ -1624,7 +1636,8 @@ int traversalCode (int key, int theEvent) { } boolean useSharedEditor() { - return (style & SWT.SINGLE) != 0; + /* NSSecureText uses its own editor instead of the window's shared editor */ + return (style & (SWT.SINGLE | SWT.PASSWORD)) == SWT.SINGLE; } String verifyText (String string, int start, int end, Event keyEvent) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java index 36f8354ab5..1dc6b9a188 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java @@ -310,6 +310,9 @@ boolean clickOnLink(int textView, int link, int charIndex) { void comboBoxSelectionDidChange(int notification) { } +void controlTextDidBeginEditing(int notification) { +} + void createHandle () { } |