summaryrefslogtreecommitdiffstats
path: root/bundles
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-03-16 13:52:45 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-03-16 13:53:11 -0400
commit636180aff5bfa10aac67244a1cf386398eb5e399 (patch)
tree8288838ffac12019b05e06a2cc0c43a96128e32e /bundles
parent4827c2d4b1aa7b247c59385b3537a6f15b2dbc3c (diff)
downloadeclipse.platform.swt-636180aff5bfa10aac67244a1cf386398eb5e399.tar.gz
eclipse.platform.swt-636180aff5bfa10aac67244a1cf386398eb5e399.tar.xz
eclipse.platform.swt-636180aff5bfa10aac67244a1cf386398eb5e399.zip
Bug 241644 - Text widget with no SWT.BORDER style has no Undo or Select All key bindings
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras14
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSResponder.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSTextView.java6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Text.java32
7 files changed, 66 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index 68769bb8d6..7b1206d2e6 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -2691,6 +2691,9 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="undoManager" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="validRequestorForSendType:returnType:" swt_gen="true">
<arg swt_gen="true"></arg>
<arg swt_gen="true"></arg>
@@ -3630,6 +3633,10 @@
<method selector="selectedTextAttributes" swt_gen="true">
<retval swt_gen="true"></retval>
</method>
+ <method selector="setAllowsUndo:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setBaseWritingDirection:range:" swt_gen="true">
<arg swt_gen="true"></arg>
<arg swt_gen="true"></arg>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
index e3d0991aa2..665559a2a8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
@@ -1102,6 +1102,20 @@
</class>
<class name="NSUnarchiver" swt_superclass="NSCoder">
</class>
+ <class name="NSUndoManager" swt_gen="mixed">
+ <method selector="canRedo" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="canUndo" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="redo" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ <method selector="undo" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
+ </class>
<class name="NSUniqueIDSpecifier" swt_superclass="NSScriptObjectSpecifier">
</class>
<class name="NSValue" swt_gen="mixed">
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSResponder.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSResponder.java
index 94575b595b..7ef173ff4c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSResponder.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSResponder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -188,6 +188,11 @@ public void touchesMovedWithEvent(NSEvent event) {
OS.objc_msgSend(this.id, OS.sel_touchesMovedWithEvent_, event != null ? event.id : 0);
}
+public NSUndoManager undoManager() {
+ int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_undoManager);
+ return result != 0 ? new NSUndoManager(result) : null;
+}
+
public id validRequestorForSendType(NSString sendType, NSString returnType) {
int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_validRequestorForSendType_returnType_, sendType != null ? sendType.id : 0, returnType != null ? returnType.id : 0);
return result != 0 ? new id(result) : null;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSTextView.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSTextView.java
index bf6c1ef65e..7e0d32f4f2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSTextView.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSTextView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 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
@@ -61,6 +61,10 @@ public NSDictionary selectedTextAttributes() {
return result != 0 ? new NSDictionary(result) : null;
}
+public void setAllowsUndo(boolean flag) {
+ OS.objc_msgSend(this.id, OS.sel_setAllowsUndo_, flag);
+}
+
public void setBaseWritingDirection(int /*long*/ writingDirection, NSRange range) {
OS.objc_msgSend(this.id, OS.sel_setBaseWritingDirection_range_, writingDirection, range);
}
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 7476e2708b..f92d07ba09 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
@@ -837,6 +837,7 @@ public static final int /*long*/ class_NSURLCredential = objc_getClass("NSURLCre
public static final int /*long*/ class_NSURLDownload = objc_getClass("NSURLDownload");
public static final int /*long*/ class_NSURLProtectionSpace = objc_getClass("NSURLProtectionSpace");
public static final int /*long*/ class_NSURLRequest = objc_getClass("NSURLRequest");
+public static final int /*long*/ class_NSUndoManager = objc_getClass("NSUndoManager");
public static final int /*long*/ class_NSValue = objc_getClass("NSValue");
public static final int /*long*/ class_NSView = objc_getClass("NSView");
public static final int /*long*/ class_NSWindow = objc_getClass("NSWindow");
@@ -1039,7 +1040,9 @@ public static final int /*long*/ sel_canBecomeKeyWindow = sel_registerName("canB
public static final int /*long*/ sel_canDragRowsWithIndexes_atPoint_ = sel_registerName("canDragRowsWithIndexes:atPoint:");
public static final int /*long*/ sel_canGoBack = sel_registerName("canGoBack");
public static final int /*long*/ sel_canGoForward = sel_registerName("canGoForward");
+public static final int /*long*/ sel_canRedo = sel_registerName("canRedo");
public static final int /*long*/ sel_canShowMIMEType_ = sel_registerName("canShowMIMEType:");
+public static final int /*long*/ sel_canUndo = sel_registerName("canUndo");
public static final int /*long*/ sel_cancel = sel_registerName("cancel");
public static final int /*long*/ sel_cancelAuthenticationChallenge_ = sel_registerName("cancelAuthenticationChallenge:");
public static final int /*long*/ sel_cancelButtonCell = sel_registerName("cancelButtonCell");
@@ -1654,6 +1657,7 @@ public static final int /*long*/ sel_rectOfColumn_ = sel_registerName("rectOfCol
public static final int /*long*/ sel_rectOfRow_ = sel_registerName("rectOfRow:");
public static final int /*long*/ sel_rectValue = sel_registerName("rectValue");
public static final int /*long*/ sel_redComponent = sel_registerName("redComponent");
+public static final int /*long*/ sel_redo = sel_registerName("redo");
public static final int /*long*/ sel_reflectScrolledClipView_ = sel_registerName("reflectScrolledClipView:");
public static final int /*long*/ sel_registerForDraggedTypes_ = sel_registerName("registerForDraggedTypes:");
public static final int /*long*/ sel_release = sel_registerName("release");
@@ -1775,6 +1779,7 @@ public static final int /*long*/ sel_setAllowsColumnReordering_ = sel_registerNa
public static final int /*long*/ sel_setAllowsFloats_ = sel_registerName("setAllowsFloats:");
public static final int /*long*/ sel_setAllowsMixedState_ = sel_registerName("setAllowsMixedState:");
public static final int /*long*/ sel_setAllowsMultipleSelection_ = sel_registerName("setAllowsMultipleSelection:");
+public static final int /*long*/ sel_setAllowsUndo_ = sel_registerName("setAllowsUndo:");
public static final int /*long*/ sel_setAllowsUserCustomization_ = sel_registerName("setAllowsUserCustomization:");
public static final int /*long*/ sel_setAlpha_ = sel_registerName("setAlpha:");
public static final int /*long*/ sel_setAlphaValue_ = sel_registerName("setAlphaValue:");
@@ -2158,6 +2163,8 @@ public static final int /*long*/ sel_types = sel_registerName("types");
public static final int /*long*/ sel_typesetter = sel_registerName("typesetter");
public static final int /*long*/ sel_unarchiveObjectWithData_ = sel_registerName("unarchiveObjectWithData:");
public static final int /*long*/ sel_undefined = sel_registerName("undefined");
+public static final int /*long*/ sel_undo = sel_registerName("undo");
+public static final int /*long*/ sel_undoManager = sel_registerName("undoManager");
public static final int /*long*/ sel_unhideAllApplications_ = sel_registerName("unhideAllApplications:");
public static final int /*long*/ sel_unlockFocus = sel_registerName("unlockFocus");
public static final int /*long*/ sel_unmarkText = sel_registerName("unmarkText");
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 2c8d7e8b84..760cd911e0 100644
--- 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
@@ -742,6 +742,7 @@ void createHandle () {
id id = fieldEditorWindow.fieldEditor (true, null);
if (id != null) {
OS.object_setClass (id.id, OS.objc_getClass ("SWTEditorView"));
+ new NSTextView(id).setAllowsUndo(true);
}
}
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 89e448a148..5bb6fff95b 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
@@ -505,6 +505,7 @@ void createHandle () {
NSTextView widget = (NSTextView) new SWTTextView ().alloc ();
widget.init ();
widget.setEditable ((style & SWT.READ_ONLY) == 0);
+ widget.setAllowsUndo(true);
NSSize size = new NSSize ();
size.width = size.height = Float.MAX_VALUE;
@@ -1539,13 +1540,8 @@ boolean sendKeyEvent (NSEvent nsEvent, int type) {
boolean result = super.sendKeyEvent (nsEvent, type);
if (!result) return result;
if (type != SWT.KeyDown) return result;
- int stateMask = 0;
int /*long*/ modifierFlags = nsEvent.modifierFlags();
- if ((modifierFlags & OS.NSAlternateKeyMask) != 0) stateMask |= SWT.ALT;
- if ((modifierFlags & OS.NSShiftKeyMask) != 0) stateMask |= SWT.SHIFT;
- if ((modifierFlags & OS.NSControlKeyMask) != 0) stateMask |= SWT.CONTROL;
- if ((modifierFlags & OS.NSCommandKeyMask) != 0) stateMask |= SWT.COMMAND;
- if (stateMask == SWT.COMMAND) {
+ if ((modifierFlags & OS.NSCommandKeyMask) != 0) {
short keyCode = nsEvent.keyCode ();
switch (keyCode) {
case 7: /* X */
@@ -1557,8 +1553,32 @@ boolean sendKeyEvent (NSEvent nsEvent, int type) {
case 9: /* V */
paste ();
return false;
+ case 0: /* A */
+ NSApplication.sharedApplication().sendAction(OS.sel_selectAll_, null, NSApplication.sharedApplication());
+ return false;
+ case 6: /* Z */
+ NSUndoManager undoManager = view.undoManager();
+ if (undoManager == null && (style & SWT.SINGLE) != 0) {
+ NSText fieldEditor = ((NSTextField) view).currentEditor ();
+ undoManager = fieldEditor.undoManager();
+ }
+ if (undoManager != null) {
+ if ((modifierFlags & OS.NSShiftKeyMask) != 0) {
+ if (undoManager.canRedo()) {
+ undoManager.redo();
+ return false;
+ }
+ } else {
+ if (undoManager.canUndo()) {
+ undoManager.undo();
+ return false;
+ }
+ }
+ }
+ break;
}
}
+ if (isDisposed()) return false;
if ((style & SWT.SINGLE) != 0) {
short keyCode = nsEvent.keyCode ();
switch (keyCode) {