Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2008-06-17 18:10:15 +0000
committerSilenio Quarti2008-06-17 18:10:15 +0000
commitd62d95171d1b9884e29ffebb40505397ee01c22b (patch)
tree5c2eabe1fe69963ef87290e358018196f497e902
parent1802dd1c5c905d6eb8a9a43eba713fd29752bad3 (diff)
downloadeclipse.platform.swt-d62d95171d1b9884e29ffebb40505397ee01c22b.tar.gz
eclipse.platform.swt-d62d95171d1b9884e29ffebb40505397ee01c22b.tar.xz
eclipse.platform.swt-d62d95171d1b9884e29ffebb40505397ee01c22b.zip
setInputState stateMask for mouse buttons
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java54
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Widget.java138
2 files changed, 51 insertions, 141 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
index 35d301a762..805dd87e64 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java
@@ -1565,58 +1565,6 @@ void scrollWheel (int id, int sel, int theEvent) {
super.scrollWheel(id, sel, theEvent);
}
-boolean setInputState (Event event, NSEvent nsEvent, int type) {
- if (nsEvent == null) return true;
- int modifierFlags = nsEvent.modifierFlags();
- if ((modifierFlags & OS.NSAlternateKeyMask) != 0) event.stateMask |= SWT.ALT;
- if ((modifierFlags & OS.NSShiftKeyMask) != 0) event.stateMask |= SWT.SHIFT;
- if ((modifierFlags & OS.NSControlKeyMask) != 0) event.stateMask |= SWT.CONTROL;
- if ((modifierFlags & OS.NSCommandKeyMask) != 0) event.stateMask |= SWT.COMMAND;
-
- //WRONG
- if ((modifierFlags & OS.NSLeftMouseDownMask) != 0) event.stateMask |= SWT.BUTTON1;
- if ((modifierFlags & OS.NSLeftMouseDraggedMask) != 0) event.stateMask |= SWT.BUTTON1;
- if ((modifierFlags & OS.NSLeftMouseUpMask) != 0) event.stateMask |= SWT.BUTTON1;
- if ((modifierFlags & OS.NSOtherMouseDownMask) != 0) event.stateMask |= SWT.BUTTON2;
- if ((modifierFlags & OS.NSOtherMouseDraggedMask) != 0) event.stateMask |= SWT.BUTTON2;
- if ((modifierFlags & OS.NSOtherMouseUpMask) != 0) event.stateMask |= SWT.BUTTON1;
- if ((modifierFlags & OS.NSRightMouseDownMask) != 0) event.stateMask |= SWT.BUTTON3;
- if ((modifierFlags & OS.NSRightMouseDraggedMask) != 0) event.stateMask |= SWT.BUTTON3;
- if ((modifierFlags & OS.NSRightMouseUpMask) != 0) event.stateMask |= SWT.BUTTON3;
-
-// if (OS.GetKeyState (OS.VK_XBUTTON1) < 0) event.stateMask |= SWT.BUTTON4;
-// if (OS.GetKeyState (OS.VK_XBUTTON2) < 0) event.stateMask |= SWT.BUTTON5;
-// switch (type) {
-// case SWT.MouseDown:
-// case SWT.MouseDoubleClick:
-// if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
-// if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
-// if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
-// if (event.button == 4) event.stateMask &= ~SWT.BUTTON4;
-// if (event.button == 5) event.stateMask &= ~SWT.BUTTON5;
-// break;
-// case SWT.MouseUp:
-// if (event.button == 1) event.stateMask |= SWT.BUTTON1;
-// if (event.button == 2) event.stateMask |= SWT.BUTTON2;
-// if (event.button == 3) event.stateMask |= SWT.BUTTON3;
-// if (event.button == 4) event.stateMask |= SWT.BUTTON4;
-// if (event.button == 5) event.stateMask |= SWT.BUTTON5;
-// break;
-// case SWT.KeyDown:
-// case SWT.Traverse:
-// if (event.keyCode == SWT.ALT) event.stateMask &= ~SWT.ALT;
-// if (event.keyCode == SWT.SHIFT) event.stateMask &= ~SWT.SHIFT;
-// if (event.keyCode == SWT.CONTROL) event.stateMask &= ~SWT.CONTROL;
-// break;
-// case SWT.KeyUp:
-// if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
-// if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
-// if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
-// break;
-// }
- return true;
-}
-
void mouseDown(int id, int sel, int theEvent) {
Display display = this.display;
display.trackingControl = this;
@@ -2244,7 +2192,7 @@ boolean sendDragEvent (int button, int chord, int modifiers, int x, int y) {
}
event.x = x;
event.y = y;
- setInputState (event, SWT.DragDetect, chord, modifiers);
+// setInputState (event, SWT.DragDetect, chord, modifiers);
postEvent (SWT.DragDetect, event);
return event.doit;
}
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 7bdc26f16a..b1a38fd1e3 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
@@ -1106,94 +1106,56 @@ void setFrameSize (int id, int sel, NSSize size) {
OS.objc_msgSendSuper(super_struct, sel, size);
}
-boolean setInputState (Event event, int type, int chord, int modifiers) {
-// if ((chord & 0x01) != 0) event.stateMask |= SWT.BUTTON1;
-// if ((chord & 0x02) != 0) event.stateMask |= SWT.BUTTON3;
-// if ((chord & 0x04) != 0) event.stateMask |= SWT.BUTTON2;
-// if ((chord & 0x08) != 0) event.stateMask |= SWT.BUTTON4;
-// if ((chord & 0x10) != 0) event.stateMask |= SWT.BUTTON5;
-//
-// if ((modifiers & OS.optionKey) != 0) event.stateMask |= SWT.ALT;
-// if ((modifiers & OS.shiftKey) != 0) event.stateMask |= SWT.SHIFT;
-// if ((modifiers & OS.controlKey) != 0) event.stateMask |= SWT.CONTROL;
-// if ((modifiers & OS.cmdKey) != 0) event.stateMask |= SWT.COMMAND;
-// switch (type) {
-// case SWT.MouseDown:
-// case SWT.MouseDoubleClick:
-// if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
-// if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
-// if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
-// if (event.button == 4) event.stateMask &= ~SWT.BUTTON4;
-// if (event.button == 5) event.stateMask &= ~SWT.BUTTON5;
-// break;
-// case SWT.MouseUp:
-// if (event.button == 1) event.stateMask |= SWT.BUTTON1;
-// if (event.button == 2) event.stateMask |= SWT.BUTTON2;
-// if (event.button == 3) event.stateMask |= SWT.BUTTON3;
-// if (event.button == 4) event.stateMask |= SWT.BUTTON4;
-// if (event.button == 5) event.stateMask |= SWT.BUTTON5;
-// break;
-// case SWT.KeyDown:
-// case SWT.Traverse: {
-// if (event.keyCode != 0 || event.character != 0) return true;
-// int lastModifiers = display.lastModifiers;
-// if ((modifiers & OS.alphaLock) != 0 && (lastModifiers & OS.alphaLock) == 0) {
-// event.keyCode = SWT.CAPS_LOCK;
-// return true;
-// }
-// if ((modifiers & OS.shiftKey) != 0 && (lastModifiers & OS.shiftKey) == 0) {
-// event.stateMask &= ~SWT.SHIFT;
-// event.keyCode = SWT.SHIFT;
-// return true;
-// }
-// if ((modifiers & OS.controlKey) != 0 && (lastModifiers & OS.controlKey) == 0) {
-// event.stateMask &= ~SWT.CONTROL;
-// event.keyCode = SWT.CONTROL;
-// return true;
-// }
-// if ((modifiers & OS.cmdKey) != 0 && (lastModifiers & OS.cmdKey) == 0) {
-// event.stateMask &= ~SWT.COMMAND;
-// event.keyCode = SWT.COMMAND;
-// return true;
-// }
-// if ((modifiers & OS.optionKey) != 0 && (lastModifiers & OS.optionKey) == 0) {
-// event.stateMask &= ~SWT.ALT;
-// event.keyCode = SWT.ALT;
-// return true;
-// }
-// break;
-// }
-// case SWT.KeyUp: {
-// if (event.keyCode != 0 || event.character != 0) return true;
-// int lastModifiers = display.lastModifiers;
-// if ((modifiers & OS.alphaLock) == 0 && (lastModifiers & OS.alphaLock) != 0) {
-// event.keyCode = SWT.CAPS_LOCK;
-// return true;
-// }
-// if ((modifiers & OS.shiftKey) == 0 && (lastModifiers & OS.shiftKey) != 0) {
-// event.stateMask |= SWT.SHIFT;
-// event.keyCode = SWT.SHIFT;
-// return true;
-// }
-// if ((modifiers & OS.controlKey) == 0 && (lastModifiers & OS.controlKey) != 0) {
-// event.stateMask |= SWT.CONTROL;
-// event.keyCode = SWT.CONTROL;
-// return true;
-// }
-// if ((modifiers & OS.cmdKey) == 0 && (lastModifiers & OS.cmdKey) != 0) {
-// event.stateMask |= SWT.COMMAND;
-// event.keyCode = SWT.COMMAND;
-// return true;
-// }
-// if ((modifiers & OS.optionKey) == 0 && (lastModifiers & OS.optionKey) != 0) {
-// event.stateMask |= SWT.ALT;
-// event.keyCode = SWT.ALT;
-// return true;
-// }
-// break;
-// }
-// }
- return true;
+boolean setInputState (Event event, NSEvent nsEvent, int type) {
+ if (nsEvent == null) return true;
+ int modifierFlags = nsEvent.modifierFlags();
+ if ((modifierFlags & OS.NSAlternateKeyMask) != 0) event.stateMask |= SWT.ALT;
+ if ((modifierFlags & OS.NSShiftKeyMask) != 0) event.stateMask |= SWT.SHIFT;
+ if ((modifierFlags & OS.NSControlKeyMask) != 0) event.stateMask |= SWT.CONTROL;
+ if ((modifierFlags & OS.NSCommandKeyMask) != 0) event.stateMask |= SWT.COMMAND;
+ //TODO multiple mouse buttons pressed
+ switch (nsEvent.type()) {
+ case OS.NSLeftMouseDragged:
+ case OS.NSRightMouseDragged:
+ case OS.NSOtherMouseDragged:
+ switch (nsEvent.buttonNumber()) {
+ case 0: event.stateMask |= SWT.BUTTON1; break;
+ case 1: event.stateMask |= SWT.BUTTON3; break;
+ case 2: event.stateMask |= SWT.BUTTON2; break;
+ case 3: event.stateMask |= SWT.BUTTON4; break;
+ case 4: event.stateMask |= SWT.BUTTON5; break;
+ }
+ break;
+ }
+ switch (type) {
+ case SWT.MouseDown:
+ case SWT.MouseDoubleClick:
+ if (event.button == 1) event.stateMask &= ~SWT.BUTTON1;
+ if (event.button == 2) event.stateMask &= ~SWT.BUTTON2;
+ if (event.button == 3) event.stateMask &= ~SWT.BUTTON3;
+ if (event.button == 4) event.stateMask &= ~SWT.BUTTON4;
+ if (event.button == 5) event.stateMask &= ~SWT.BUTTON5;
+ break;
+ case SWT.MouseUp:
+ if (event.button == 1) event.stateMask |= SWT.BUTTON1;
+ if (event.button == 2) event.stateMask |= SWT.BUTTON2;
+ if (event.button == 3) event.stateMask |= SWT.BUTTON3;
+ if (event.button == 4) event.stateMask |= SWT.BUTTON4;
+ if (event.button == 5) event.stateMask |= SWT.BUTTON5;
+ break;
+ case SWT.KeyDown:
+ case SWT.Traverse:
+ if (event.keyCode == SWT.ALT) event.stateMask &= ~SWT.ALT;
+ if (event.keyCode == SWT.SHIFT) event.stateMask &= ~SWT.SHIFT;
+ if (event.keyCode == SWT.CONTROL) event.stateMask &= ~SWT.CONTROL;
+ break;
+ case SWT.KeyUp:
+ if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
+ if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
+ if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
+ break;
+ }
+ return true;
}
boolean setKeyState (Event event, int type, NSEvent nsEvent) {

Back to the top