summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-12-06 15:58:39 +0000
committerbelugas <belugas@openttd.org>2007-12-06 15:58:39 +0000
commit6c70cf2d82cac252b9e48d53e70aaeb15f7b9ad6 (patch)
treed4681689d02a94b5e02cee2582442148b9d596e6 /src/window.cpp
parent7edf28529dad8d0619d10c27a480eeca7a896321 (diff)
downloadopenttd-6c70cf2d82cac252b9e48d53e70aaeb15f7b9ad6.tar.xz
(svn r11579) -Revert(r11578): some cases of key propagation are not handled correctly.
A better solution will be deviced, but not now. Let's not cause a ton of bug reports
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/window.cpp b/src/window.cpp
index b20ae4b68..33063fbeb 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1676,6 +1676,10 @@ void HandleKeypress(uint32 key)
{
Window* const *wz;
WindowEvent e;
+ /* 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;
/*
* During the generation of the world, there might be
@@ -1694,12 +1698,28 @@ void HandleKeypress(uint32 key)
e.we.keypress.keycode = GB(key, 16, 16);
e.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 ||
+ FindWindowById(WC_GENERATE_LANDSCAPE, 0) != NULL ||
+ FindWindowById(WC_CONSOLE, 0) != NULL ||
+ FindWindowById(WC_SAVELOAD, 0) != NULL ||
+ FindWindowById(WC_COMPANY_PASSWORD_WINDOW, 0) != NULL) {
+ query_open = true;
+ }
+
/* Call the event, start with the uppermost window. */
for (wz = _last_z_window; wz != _z_windows;) {
Window *w = *--wz;
- /* Only call the event for the windows declared as been text entry enabled */
- if (!(w->desc_flags & WDF_TEXTENTRY)) {
+ /* 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_GENERATE_LANDSCAPE &&
+ w->window_class != WC_CONSOLE &&
+ w->window_class != WC_SAVELOAD &&
+ w->window_class != WC_COMPANY_PASSWORD_WINDOW) {
continue;
}
w->wndproc(w, &e);