mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
(svn r26002) -Fix: [OSX] If the console hotkey is a dead key, require two presses to toggle the console, allowing input of accented characters.
This commit is contained in:
parent
8ceef6ec61
commit
8f8173c3fe
@ -272,8 +272,10 @@ static uint32 QZ_MapKey(unsigned short sym)
|
||||
return key;
|
||||
}
|
||||
|
||||
static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL down)
|
||||
static bool QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL down)
|
||||
{
|
||||
bool interpret_keys = true;
|
||||
|
||||
switch (keycode) {
|
||||
case QZ_UP: SB(_dirkeys, 1, 1, down); break;
|
||||
case QZ_DOWN: SB(_dirkeys, 3, 1, down); break;
|
||||
@ -292,6 +294,21 @@ static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
|
||||
|
||||
if (down) {
|
||||
uint32 pressed_key = QZ_MapKey(keycode);
|
||||
|
||||
static bool console = false;
|
||||
|
||||
if (pressed_key == WKC_BACKQUOTE && unicode == 0) {
|
||||
if (!console) {
|
||||
/* Backquote is a dead key, require a double press for hotkey behaviour (i.e. console). */
|
||||
console = true;
|
||||
return true;
|
||||
} else {
|
||||
/* Second backquote, don't interpret as text input. */
|
||||
interpret_keys = false;
|
||||
}
|
||||
}
|
||||
console = false;
|
||||
|
||||
/* Don't handle normal characters if an edit box has the focus. */
|
||||
if (!EditBoxInGlobalFocus() || (!IsInsideMM(pressed_key, 'A', 'Z' + 1) && !IsInsideMM(pressed_key, '0', '9' + 1))) {
|
||||
HandleKeypress(pressed_key, unicode);
|
||||
@ -300,6 +317,8 @@ static void QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
|
||||
} else {
|
||||
DEBUG(driver, 2, "cocoa_v: QZ_KeyEvent: %x (%x), up", keycode, unicode);
|
||||
}
|
||||
|
||||
return interpret_keys;
|
||||
}
|
||||
|
||||
static void QZ_DoUnsidedModifiers(unsigned int newMods)
|
||||
@ -521,8 +540,9 @@ static bool QZ_PollEvent()
|
||||
}
|
||||
|
||||
if (EditBoxInGlobalFocus()) {
|
||||
if (QZ_KeyEvent([ event keyCode ], 0, YES)) {
|
||||
[ _cocoa_subdriver->cocoaview interpretKeyEvents:[ NSArray arrayWithObject:event ] ];
|
||||
QZ_KeyEvent([ event keyCode ], 0, YES);
|
||||
}
|
||||
} else {
|
||||
chars = [ event characters ];
|
||||
if ([ chars length ] == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user