summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfonsinchen <fonsinchen@openttd.org>2014-10-26 20:01:36 +0000
committerfonsinchen <fonsinchen@openttd.org>2014-10-26 20:01:36 +0000
commit306b6a11eea4ad5c8f27122e79c67b09f42f97a4 (patch)
tree8950ddcc664e9c8a46d8e82108f07e0ff362ee3d
parenta468c55750b3f29e51548e81784d9e2bdf08b6ef (diff)
downloadopenttd-306b6a11eea4ad5c8f27122e79c67b09f42f97a4.tar.xz
(svn r27046) -Fix [FS#5812]: Don't require double-press from non-dead console hotkeys.
-rw-r--r--src/video/cocoa/event.mm21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/video/cocoa/event.mm b/src/video/cocoa/event.mm
index 39e6cc445..844b2dcd0 100644
--- a/src/video/cocoa/event.mm
+++ b/src/video/cocoa/event.mm
@@ -308,7 +308,8 @@ static bool QZ_KeyEvent(unsigned short keycode, unsigned short unicode, BOOL dow
static bool console = false;
- if (pressed_key == WKC_BACKQUOTE && unicode == 0) {
+ /* The second backquote may have a character, which we don't want to interpret. */
+ if (pressed_key == WKC_BACKQUOTE && (console || unicode == 0)) {
if (!console) {
/* Backquote is a dead key, require a double press for hotkey behaviour (i.e. console). */
console = true;
@@ -538,7 +539,7 @@ static bool QZ_PollEvent()
break;
#endif
- case NSKeyDown:
+ case NSKeyDown: {
/* Quit, hide and minimize */
switch ([ event keyCode ]) {
case QZ_q:
@@ -550,22 +551,20 @@ static bool QZ_PollEvent()
break;
}
+ chars = [ event characters ];
+ unsigned short unicode = [ chars length ] > 0 ? [ chars characterAtIndex:0 ] : 0;
if (EditBoxInGlobalFocus()) {
- if (QZ_KeyEvent([ event keyCode ], 0, YES)) {
+ if (QZ_KeyEvent([ event keyCode ], unicode, YES)) {
[ _cocoa_subdriver->cocoaview interpretKeyEvents:[ NSArray arrayWithObject:event ] ];
}
} else {
- chars = [ event characters ];
- if ([ chars length ] == 0) {
- QZ_KeyEvent([ event keyCode ], 0, YES);
- } else {
- QZ_KeyEvent([ event keyCode ], [ chars characterAtIndex:0 ], YES);
- for (uint i = 1; i < [ chars length ]; i++) {
- QZ_KeyEvent(0, [ chars characterAtIndex:i ], YES);
- }
+ QZ_KeyEvent([ event keyCode ], unicode, YES);
+ for (uint i = 1; i < [ chars length ]; i++) {
+ QZ_KeyEvent(0, [ chars characterAtIndex:i ], YES);
}
}
break;
+ }
case NSKeyUp:
/* Quit, hide and minimize */