1674 * 16 bits the keycode */ |
1674 * 16 bits the keycode */ |
1675 void HandleKeypress(uint32 key) |
1675 void HandleKeypress(uint32 key) |
1676 { |
1676 { |
1677 Window* const *wz; |
1677 Window* const *wz; |
1678 WindowEvent e; |
1678 WindowEvent e; |
|
1679 /* Stores if a window with a textfield for typing is open |
|
1680 * If this is the case, keypress events are only passed to windows with text fields and |
|
1681 * to thein this main toolbar. */ |
|
1682 bool query_open = false; |
1679 |
1683 |
1680 /* |
1684 /* |
1681 * During the generation of the world, there might be |
1685 * During the generation of the world, there might be |
1682 * another thread that is currently building for example |
1686 * another thread that is currently building for example |
1683 * a road. To not interfere with those tasks, we should |
1687 * a road. To not interfere with those tasks, we should |
1692 e.event = WE_KEYPRESS; |
1696 e.event = WE_KEYPRESS; |
1693 e.we.keypress.key = GB(key, 0, 16); |
1697 e.we.keypress.key = GB(key, 0, 16); |
1694 e.we.keypress.keycode = GB(key, 16, 16); |
1698 e.we.keypress.keycode = GB(key, 16, 16); |
1695 e.we.keypress.cont = true; |
1699 e.we.keypress.cont = true; |
1696 |
1700 |
|
1701 /* check if we have a query string window open before allowing hotkeys */ |
|
1702 if (FindWindowById(WC_QUERY_STRING, 0) != NULL || |
|
1703 FindWindowById(WC_SEND_NETWORK_MSG, 0) != NULL || |
|
1704 FindWindowById(WC_GENERATE_LANDSCAPE, 0) != NULL || |
|
1705 FindWindowById(WC_CONSOLE, 0) != NULL || |
|
1706 FindWindowById(WC_SAVELOAD, 0) != NULL || |
|
1707 FindWindowById(WC_COMPANY_PASSWORD_WINDOW, 0) != NULL) { |
|
1708 query_open = true; |
|
1709 } |
|
1710 |
1697 /* Call the event, start with the uppermost window. */ |
1711 /* Call the event, start with the uppermost window. */ |
1698 for (wz = _last_z_window; wz != _z_windows;) { |
1712 for (wz = _last_z_window; wz != _z_windows;) { |
1699 Window *w = *--wz; |
1713 Window *w = *--wz; |
1700 |
1714 |
1701 /* Only call the event for the windows declared as been text entry enabled */ |
1715 /* if a query window is open, only call the event for certain window types */ |
1702 if (!(w->desc_flags & WDF_TEXTENTRY)) { |
1716 if (query_open && |
|
1717 w->window_class != WC_QUERY_STRING && |
|
1718 w->window_class != WC_SEND_NETWORK_MSG && |
|
1719 w->window_class != WC_GENERATE_LANDSCAPE && |
|
1720 w->window_class != WC_CONSOLE && |
|
1721 w->window_class != WC_SAVELOAD && |
|
1722 w->window_class != WC_COMPANY_PASSWORD_WINDOW) { |
1703 continue; |
1723 continue; |
1704 } |
1724 } |
1705 w->wndproc(w, &e); |
1725 w->wndproc(w, &e); |
1706 if (!e.we.keypress.cont) break; |
1726 if (!e.we.keypress.cont) break; |
1707 } |
1727 } |