summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2009-01-21 00:37:52 +0000
committerSilenio Quarti <silenio>2009-01-21 00:37:52 +0000
commitd83561e2a470cacc6095411b57b2532529e6968b (patch)
tree295690f0f4d61b40d9bfeda025cae8b1877ae678 /bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt
parent90874dd0f318ad72c86947cdc4c25287bab952a0 (diff)
downloadeclipse.platform.swt-d83561e2a470cacc6095411b57b2532529e6968b.tar.gz
eclipse.platform.swt-d83561e2a470cacc6095411b57b2532529e6968b.tar.xz
eclipse.platform.swt-d83561e2a470cacc6095411b57b2532529e6968b.zip
Bug 153432 - [KeyBindings] Unicode keyboards on Mac OSX produce wrong keys when used with modifiers
258877 - Command-key shortcuts always interpreted as QWERTY, even in DVORAK input mode
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java64
1 files changed, 43 insertions, 21 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
index 89b8c2ffb5..18f50f58cd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Widget.java
@@ -1944,29 +1944,51 @@ boolean setKeyState (Event event, int type, int theEvent) {
display.kchrPtr = kchrPtr;
display.kchrState [0] = 0;
}
- int result = OS.KeyTranslate (display.kchrPtr, (short)keyCode [0], display.kchrState);
- if (result <= 0x7f) {
- event.keyCode = result & 0x7f;
+ int [] layoutRef = new int [1];
+ int layoutKind = OS.kKLKCHRKind;
+ if (OS.KLGetCurrentKeyboardLayout (layoutRef) == OS.noErr) {
+ int [] layoutKindRef = new int [1];
+ OS.KLGetKeyboardLayoutProperty (layoutRef[0], OS.kKLKind, layoutKindRef);
+ layoutKind = layoutKindRef [0];
+ }
+ if (layoutKind == OS.kKLuchrKind) {
+ int [] layoutPtr = new int [1];
+ OS.KLGetKeyboardLayoutProperty (layoutRef[0], OS.kKLuchrData, layoutPtr);
+ int maxStringLength = 256;
+ char [] output = new char [maxStringLength];
+ int [] actualStringLength = new int [1];
+ OS.UCKeyTranslate (layoutPtr[0], (short)keyCode[0], (short)OS.kUCKeyActionDown, 0, OS.LMGetKbdType (), 0, display.kchrState, maxStringLength, actualStringLength, output);
+ if (actualStringLength[0] < 1) {
+ // part of a multi-key key
+ event.keyCode = 0;
+ } else {
+ event.keyCode = output[0];
+ }
} else {
- int [] encoding = new int [1];
- short keyScript = (short) OS.GetScriptManagerVariable ((short) OS.smKeyScript);
- short regionCode = (short) OS.GetScriptManagerVariable ((short) OS.smRegionCode);
- if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, regionCode, null, encoding) == OS.paramErr) {
- if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, (short) OS.kTextRegionDontCare, null, encoding) == OS.paramErr) {
- encoding [0] = OS.kTextEncodingMacRoman;
+ int result = OS.KeyTranslate (display.kchrPtr, (short)keyCode [0], display.kchrState);
+ if (result <= 0x7f) {
+ event.keyCode = result & 0x7f;
+ } else {
+ int [] encoding = new int [1];
+ short keyScript = (short) OS.GetScriptManagerVariable ((short) OS.smKeyScript);
+ short regionCode = (short) OS.GetScriptManagerVariable ((short) OS.smRegionCode);
+ if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, regionCode, null, encoding) == OS.paramErr) {
+ if (OS.UpgradeScriptInfoToTextEncoding (keyScript, (short) OS.kTextLanguageDontCare, (short) OS.kTextRegionDontCare, null, encoding) == OS.paramErr) {
+ encoding [0] = OS.kTextEncodingMacRoman;
+ }
+ }
+ int [] encodingInfo = new int [1];
+ OS.CreateTextToUnicodeInfoByEncoding (encoding [0], encodingInfo);
+ if (encodingInfo [0] != 0) {
+ char [] chars = new char [1];
+ int [] nchars = new int [1];
+ byte [] buffer = new byte [2];
+ buffer [0] = 1;
+ buffer [1] = (byte) (result & 0xFF);
+ OS.ConvertFromPStringToUnicode (encodingInfo [0], buffer, chars.length * 2, nchars, chars);
+ OS.DisposeTextToUnicodeInfo (encodingInfo);
+ event.keyCode = chars [0];
}
- }
- int [] encodingInfo = new int [1];
- OS.CreateTextToUnicodeInfoByEncoding (encoding [0], encodingInfo);
- if (encodingInfo [0] != 0) {
- char [] chars = new char [1];
- int [] nchars = new int [1];
- byte [] buffer = new byte [2];
- buffer [0] = 1;
- buffer [1] = (byte) (result & 0xFF);
- OS.ConvertFromPStringToUnicode (encodingInfo [0], buffer, chars.length * 2, nchars, chars);
- OS.DisposeTextToUnicodeInfo (encodingInfo);
- event.keyCode = chars [0];
}
}
}