(svn r11578) -Codechange: Introduce the window default flag WDF_TEXTENTRY which specifies that the window holding it is actually one that enables an edit box.

Use this flag when dispatching a key event instead of using some hard coded window IDs.
This should ease a little bit the creation of new edit aware windows.
This commit is contained in:
belugas
2007-12-06 02:31:47 +00:00
parent 9cab7af581
commit cc29d43876
8 changed files with 14 additions and 34 deletions

View File

@@ -1676,10 +1676,6 @@ 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
@@ -1698,28 +1694,12 @@ 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;
/* 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) {
/* Only call the event for the windows declared as been text entry enabled */
if (!(w->desc_flags & WDF_TEXTENTRY)) {
continue;
}
w->wndproc(w, &e);