summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio_quarti@ca.ibm.com>2012-09-28 10:09:15 -0400
committerSilenio Quarti <silenio_quarti@ca.ibm.com>2012-09-28 10:09:36 -0400
commite9024966202f6bd2eaef5f6ebebe83ee37dcb74e (patch)
treeabd6d0b0ed06d130b1130a00325ac6b694e7cae2
parent4e95e9822f38553154d401b66a8ec9a218291978 (diff)
downloadeclipse.platform.swt-e9024966202f6bd2eaef5f6ebebe83ee37dcb74e.tar.gz
eclipse.platform.swt-e9024966202f6bd2eaef5f6ebebe83ee37dcb74e.tar.xz
eclipse.platform.swt-e9024966202f6bd2eaef5f6ebebe83ee37dcb74e.zip
Bug 385253 - SWT does not send SWT.KeyDown event when pressing down key in combo control
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Combo.java27
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java15
2 files changed, 35 insertions, 7 deletions
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 fb7606e78d..b37b1245d1 100644
--- 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
@@ -457,12 +457,12 @@ void createWidget() {
}
void comboBoxWillDismiss(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) {
- display.comboPoppedUp = false;
+ display.currentCombo = null;
listVisible = false;
}
void comboBoxWillPopUp(long /*int*/ id, long /*int*/ sel, long /*int*/ notification) {
- display.comboPoppedUp = true;
+ display.currentCombo = this;
listVisible = true;
}
@@ -1089,6 +1089,9 @@ void register() {
}
void releaseWidget () {
+ if (display.currentCombo == this) {
+ display.currentCombo = null;
+ }
super.releaseWidget ();
if ((style & SWT.READ_ONLY) == 0) {
((NSControl)view).abortEditing();
@@ -1344,6 +1347,26 @@ boolean sendKeyEvent (NSEvent nsEvent, int type) {
return result;
}
+boolean sendTrackingKeyEvent (NSEvent nsEvent, int type) {
+ /*
+ * Feature in Cocoa. Combo does not send arrow down/up
+ * key down events while the list is showing. The fix is
+ * to send these events when the event is removed from the
+ * queue.
+ */
+ long /*int*/ modifiers = nsEvent.modifierFlags();
+ if ((modifiers & OS.NSShiftKeyMask) == 0) {
+ short keyCode = nsEvent.keyCode ();
+ switch (keyCode) {
+ case 125: /* Arrow Down */
+ case 126: /* Arrow Up */
+ sendKeyEvent(nsEvent, type);
+ return true;
+ }
+ }
+ return false;
+}
+
void setBackgroundColor(NSColor nsColor) {
if ((style & SWT.READ_ONLY) != 0) {
//TODO
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 c128986f69..4c066e658a 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
@@ -176,7 +176,7 @@ public class Display extends Device {
long /*int*/ oldCursorSetProc;
Callback cursorSetCallback;
- boolean comboPoppedUp = false;
+ Combo currentCombo;
boolean mozillaRunning;
static final String MOZILLA_RUNNING = "org.eclipse.swt.internal.mozillaRunning"; //$NON-NLS-1$
@@ -4892,10 +4892,15 @@ long /*int*/ applicationNextEventMatchingMask (long /*int*/ id, long /*int*/ sel
* workaround is to detect this case and to not return the event that would trigger
* this to happen.
*/
- if (comboPoppedUp && mozillaRunning && dequeue != 0) {
- NSEvent event = new NSEvent(result);
- if (event.type() == OS.NSApplicationDefined) {
- return 0;
+ if (dequeue != 0 && currentCombo != null && !currentCombo.isDisposed()) {
+ NSEvent nsEvent = new NSEvent(result);
+ if (mozillaRunning) {
+ if (nsEvent.type() == OS.NSApplicationDefined) {
+ return 0;
+ }
+ }
+ if (nsEvent.type() == OS.NSKeyDown) {
+ currentCombo.sendTrackingKeyEvent(nsEvent, SWT.KeyDown);
}
}
if (dequeue != 0 && trackingControl != null && !trackingControl.isDisposed()) {