diff options
-rw-r--r-- | rail_gui.c | 4 | ||||
-rw-r--r-- | road_gui.c | 4 | ||||
-rw-r--r-- | terraform_gui.c | 4 | ||||
-rw-r--r-- | window.c | 11 |
4 files changed, 11 insertions, 12 deletions
diff --git a/rail_gui.c b/rail_gui.c index ac22977e0..36d13ba74 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -613,10 +613,6 @@ static void BuildRailToolbWndProc(Window *w, WindowEvent *e) case WE_KEYPRESS: { int i; - // check if we have a query string window open before allowing hotkeys - if(FindWindowById(WC_QUERY_STRING, 0)!=NULL) - break; - for(i=0; i!=lengthof(_rail_keycodes); i++) if (e->keypress.keycode == _rail_keycodes[i]) { e->keypress.cont = false; diff --git a/road_gui.c b/road_gui.c index b1add67b0..8374786b4 100644 --- a/road_gui.c +++ b/road_gui.c @@ -192,10 +192,6 @@ static void BuildRoadToolbWndProc(Window *w, WindowEvent *e) { } break; case WE_KEYPRESS: - // check if we have a query string window open before allowing hotkeys - if(FindWindowById(WC_QUERY_STRING, 0)!=NULL) - break; - switch(e->keypress.keycode) { case '1': BuildRoadClick_NE(w); break; case '2': BuildRoadClick_NW(w); break; diff --git a/terraform_gui.c b/terraform_gui.c index 82cfffd96..6c8f915e9 100644 --- a/terraform_gui.c +++ b/terraform_gui.c @@ -122,10 +122,6 @@ static void TerraformToolbWndProc(Window *w, WindowEvent *e) { int i; - // check if we have a query string window open before allowing hotkeys - if(FindWindowById(WC_QUERY_STRING, 0)!=NULL) - break; - for(i=0; i!=lengthof(_terraform_keycodes); i++) if (e->keypress.keycode == _terraform_keycodes[i]) { e->keypress.cont = false; @@ -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; |