summaryrefslogtreecommitdiff
path: root/window.c
diff options
context:
space:
mode:
authordominik <dominik@openttd.org>2004-12-14 17:38:48 +0000
committerdominik <dominik@openttd.org>2004-12-14 17:38:48 +0000
commit23612e41f2a01b726d7aa9f29f45eb501cf71882 (patch)
tree72f658811e8b9980bf33a0469017c222b8ace2d7 /window.c
parenta94da5937c1f960958383b05fdbebeda577a0c79 (diff)
downloadopenttd-23612e41f2a01b726d7aa9f29f45eb501cf71882.tar.xz
(svn r1084) Generalized hotkey catching when textfield windows are open. Now only hotkeys attached to the main toolbar are working if you have a textfield open.
Diffstat (limited to 'window.c')
-rw-r--r--window.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/window.c b/window.c
index a24afb7c4..ba0e488dd 100644
--- a/window.c
+++ b/window.c
@@ -1054,6 +1054,10 @@ static void HandleKeypress(uint32 key)
{
Window *w;
WindowEvent we;
+ /* Stores if a window with a textfield for typing is open
+ * If this is the case, keypress events are only passed to windows with text fields and
+ * to thein this main toolbar. */
+ bool query_open = false;
// Setup event
we.keypress.event = WE_KEYPRESS;
@@ -1061,9 +1065,16 @@ static void HandleKeypress(uint32 key)
we.keypress.keycode = key >> 16;
we.keypress.cont = true;
+ // check if we have a query string window open before allowing hotkeys
+ if(FindWindowById(WC_QUERY_STRING, 0)!=NULL || FindWindowById(WC_SEND_NETWORK_MSG, 0)!=NULL)
+ query_open = true;
+
// Call the event, start with the uppermost window.
for(w=_last_window; w != _windows;) {
--w;
+ // if a query window is open, only call the event for certain window types
+ if(query_open && w->window_class!=WC_QUERY_STRING && w->window_class!=WC_SEND_NETWORK_MSG && w->window_class!=WC_MAIN_TOOLBAR)
+ continue;
w->wndproc(w, &we);
if (!we.keypress.cont)
break;