Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Barnes2008-06-12 21:27:39 +0000
committerKevin Barnes2008-06-12 21:27:39 +0000
commit8286350fbb02a99764bf55774832988bc9a5aef8 (patch)
treeb266fd2900010361cbf82cdc610c0d865b28620e
parentb09ad7a4d6dcfff9f68ecfc831954b32a6162184 (diff)
downloadeclipse.platform.swt-8286350fbb02a99764bf55774832988bc9a5aef8.tar.gz
eclipse.platform.swt-8286350fbb02a99764bf55774832988bc9a5aef8.tar.xz
eclipse.platform.swt-8286350fbb02a99764bf55774832988bc9a5aef8.zip
key events from flagsChanged working for StyledText
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Control.java37
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java9
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java36
3 files changed, 42 insertions, 40 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 5dc98d6fc7..0cedc451ad 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
@@ -817,6 +817,43 @@ void fixFocus (Control focusControl) {
// OS.ClearKeyboardFocus (window);
}
+void flagsChanged(int theEvent) {
+ Display display = this.display;
+ NSEvent nsEvent = new NSEvent(theEvent);
+ int modifiers = nsEvent.modifierFlags();
+ int lastModifiers = display.lastModifiers;
+// int chord = OS.GetCurrentEventButtonState ();
+ int type = SWT.KeyUp;
+ if ((modifiers & OS.NSAlphaShiftKeyMask) != 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) == 0) type = SWT.KeyDown;
+ if ((modifiers & OS.NSAlternateKeyMask) != 0 && (lastModifiers & OS.NSAlternateKeyMask) == 0) type = SWT.KeyDown;
+ if ((modifiers & OS.NSShiftKeyMask) != 0 && (lastModifiers & OS.NSShiftKeyMask) == 0) type = SWT.KeyDown;
+ if ((modifiers & OS.NSControlKeyMask) != 0 && (lastModifiers & OS.NSControlKeyMask) == 0) type = SWT.KeyDown;
+ if ((modifiers & OS.NSCommandKeyMask) != 0 && (lastModifiers & OS.NSCommandKeyMask) == 0) type = SWT.KeyDown;
+ Control target = display.getFocusControl();
+ if (type == SWT.KeyUp && (modifiers & OS.NSAlphaShiftKeyMask) == 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) != 0) {
+ if (target != null) {
+ Event event = new Event ();
+ event.keyCode = SWT.CAPS_LOCK;
+ setInputState(event, nsEvent, type);
+ target.sendKeyEvent (SWT.KeyDown, event);
+ }
+ }
+ Event event = new Event ();
+ event.keyCode = Display.translateKey(nsEvent.keyCode());
+ setInputState(event, nsEvent, type);
+ if (event.keyCode == 0 && event.character == 0) return;
+ boolean result = sendKeyEvent (type, event);
+ if (type == SWT.KeyDown && (modifiers & OS.NSAlphaShiftKeyMask) != 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) == 0) {
+ if (target != null) {
+ event = new Event ();
+ event.keyCode = SWT.CAPS_LOCK;
+ // setInputState (event, SWT.KeyUp, chord, modifiers);
+ target.sendKeyEvent (SWT.KeyUp, event);
+ }
+ }
+ display.lastModifiers = modifiers;
+}
+
/**
* Forces the receiver to have the <em>keyboard focus</em>, causing
* all keyboard events to be delivered to it.
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 76aa901fa2..080e1341ee 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
@@ -147,10 +147,10 @@ public class Display extends Device {
static int [] [] KeyTable = {
/* Keyboard and Mouse Masks */
-// {58, SWT.ALT},
-// {56, SWT.SHIFT},
-// {59, SWT.CONTROL},
-// {55, SWT.COMMAND},
+ {58, SWT.ALT},
+ {56, SWT.SHIFT},
+ {59, SWT.CONTROL},
+ {55, SWT.COMMAND},
/* Non-Numeric Keypad Keys */
{OS.NSUpArrowFunctionKey, SWT.ARROW_UP},
@@ -1657,6 +1657,7 @@ void initClasses () {
OS.class_addMethod(cls, OS.sel_resignFirstResponder, proc2, "@:");
OS.class_addMethod(cls, OS.sel_becomeFirstResponder, proc2, "@:");
OS.class_addMethod(cls, OS.sel_isOpaque, proc2, "@:");
+ OS.class_addMethod(cls, OS.sel_flagsChanged_1, proc3, "@:@");
addEventMethods(cls, proc2, proc3);
OS.objc_registerClassPair(cls);
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 6c336cc094..255f601e7f 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
@@ -531,42 +531,6 @@ void fixShell (Shell newShell, Control control) {
// if (control == lastActive) setActiveControl (null);
}
-void flagsChanged(int theEvent) {
- Display display = this.display;
- NSEvent nsEvent = new NSEvent(theEvent);
- int modifiers = nsEvent.modifierFlags();
- int lastModifiers = display.lastModifiers;
-// int chord = OS.GetCurrentEventButtonState ();
- int type = SWT.KeyUp;
- if ((modifiers & OS.NSAlphaShiftKeyMask) != 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) == 0) type = SWT.KeyDown;
- if ((modifiers & OS.NSAlternateKeyMask) != 0 && (lastModifiers & OS.NSAlternateKeyMask) == 0) type = SWT.KeyDown;
- if ((modifiers & OS.NSShiftKeyMask) != 0 && (lastModifiers & OS.NSShiftKeyMask) == 0) type = SWT.KeyDown;
- if ((modifiers & OS.NSControlKeyMask) != 0 && (lastModifiers & OS.NSControlKeyMask) == 0) type = SWT.KeyDown;
- if ((modifiers & OS.NSCommandKeyMask) != 0 && (lastModifiers & OS.NSCommandKeyMask) == 0) type = SWT.KeyDown;
- Control target = display.getFocusControl();
- if (type == SWT.KeyUp && (modifiers & OS.NSAlphaShiftKeyMask) == 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) != 0) {
- if (target != null) {
- Event event = new Event ();
- event.keyCode = SWT.CAPS_LOCK;
- // setInputState (event, SWT.KeyDown, chord, modifiers);
- target.sendKeyEvent (SWT.KeyDown, event);
- }
- }
- Event event = new Event ();
-// setInputState (event, type, chord, modifiers);
- if (event.keyCode == 0 && event.character == 0) return;
- boolean result = sendKeyEvent (type, event);
- if (type == SWT.KeyDown && (modifiers & OS.NSAlphaShiftKeyMask) != 0 && (lastModifiers & OS.NSAlphaShiftKeyMask) == 0) {
- if (target != null) {
- event = new Event ();
- event.keyCode = SWT.CAPS_LOCK;
- // setInputState (event, SWT.KeyUp, chord, modifiers);
- target.sendKeyEvent (SWT.KeyUp, event);
- }
- }
- display.lastModifiers = modifiers;
-}
-
/**
* If the receiver is visible, moves it to the top of the
* drawing order for the display on which it was created

Back to the top