fix uchr and KCHR lookup to use modern Carbon functions
svn: r4393
This commit is contained in:
parent
c7fb924982
commit
f7f05b8176
|
@ -592,9 +592,10 @@ static Bool doPreOnChar(wxWindow *in_win, wxWindow *win, wxKeyEvent *evt)
|
||||||
|
|
||||||
short wxMacDisableMods; /* If a modifier key is here, handle it specially */
|
short wxMacDisableMods; /* If a modifier key is here, handle it specially */
|
||||||
|
|
||||||
static Handle uchrHandle;
|
static void *uchrPtr;
|
||||||
static Handle KCHRHandle;
|
static void *KCHRPtr;
|
||||||
static UInt32 key_state;
|
static UInt32 key_state;
|
||||||
|
static int keyLayoutSet;
|
||||||
static SInt16 lastKeyLayoutID;
|
static SInt16 lastKeyLayoutID;
|
||||||
|
|
||||||
void wxApp::doMacKeyUpDown(Bool down)
|
void wxApp::doMacKeyUpDown(Bool down)
|
||||||
|
@ -779,22 +780,30 @@ void wxApp::doMacKeyUpDown(Bool down)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentKeyLayoutID = GetScriptVariable(GetScriptManagerVariable(smKeyScript), smScriptKeys);
|
currentKeyLayoutID = GetScriptVariable(GetScriptManagerVariable(smKeyScript), smScriptKeys);
|
||||||
if ((!uchrHandle && !KCHRHandle) || (currentKeyLayoutID != lastKeyLayoutID)) {
|
if (!keyLayoutSet || (currentKeyLayoutID != lastKeyLayoutID)) {
|
||||||
|
KeyboardLayoutRef kl;
|
||||||
key_state = 0;
|
key_state = 0;
|
||||||
KCHRHandle = GetResource('KCHR', currentKeyLayoutID);
|
if (KLGetCurrentKeyboardLayout(&kl) == noErr) {
|
||||||
if (!KCHRHandle)
|
void *p;
|
||||||
uchrHandle = GetResource('uchr', currentKeyLayoutID);
|
if (KLGetKeyboardLayoutProperty(kl, kKLKCHRData, (const void **)&p) == noErr) {
|
||||||
|
KCHRPtr = p;
|
||||||
|
} else
|
||||||
|
KCHRPtr = NULL;
|
||||||
|
if (KLGetKeyboardLayoutProperty(kl, kKLuchrData, (const void **)&p) == noErr)
|
||||||
|
uchrPtr = p;
|
||||||
else
|
else
|
||||||
uchrHandle = NULL;
|
uchrPtr = NULL;
|
||||||
|
}
|
||||||
lastKeyLayoutID = currentKeyLayoutID;
|
lastKeyLayoutID = currentKeyLayoutID;
|
||||||
|
keyLayoutSet = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!uchrHandle) {
|
if (!uchrPtr) {
|
||||||
if (!KCHRHandle) {
|
if (!KCHRPtr) {
|
||||||
akey = '?';
|
akey = '?';
|
||||||
} else {
|
} else {
|
||||||
int trans;
|
int trans;
|
||||||
trans = KeyTranslate(*KCHRHandle, akey | mods, &key_state);
|
trans = KeyTranslate(KCHRPtr, akey | mods, &key_state);
|
||||||
if (trans & 0xFF0000) {
|
if (trans & 0xFF0000) {
|
||||||
/* 2-byte result */
|
/* 2-byte result */
|
||||||
cstr[0] = (trans & 0xFF0000) >> 16;
|
cstr[0] = (trans & 0xFF0000) >> 16;
|
||||||
|
@ -810,7 +819,7 @@ void wxApp::doMacKeyUpDown(Bool down)
|
||||||
from_str = 1;
|
from_str = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
key_layout = (UCKeyboardLayout *)*uchrHandle;
|
key_layout = (UCKeyboardLayout *)uchrPtr;
|
||||||
|
|
||||||
status = UCKeyTranslate(key_layout,
|
status = UCKeyTranslate(key_layout,
|
||||||
akey,
|
akey,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user