Index: src/genworld_gui.cpp =================================================================== --- src/genworld_gui.cpp (revision 14512) +++ src/genworld_gui.cpp (working copy) @@ -372,10 +372,6 @@ this->SetDirty(); break; - case GLAND_RANDOM_EDITBOX: // edit box for random seed - ShowOnScreenKeyboard(this, GLAND_RANDOM_EDITBOX, 0, 0); - break; - case GLAND_GENERATE_BUTTON: // Generate _settings_game = _settings_newgame; Index: src/misc_gui.cpp =================================================================== --- src/misc_gui.cpp (revision 14512) +++ src/misc_gui.cpp (working copy) @@ -1051,6 +1051,11 @@ this->QueryString::DrawEditBox(this, wid); } +void QueryStringBaseWindow::OnOpenOSKWindow(int wid) +{ + ShowOnScreenKeyboard(this, wid, 0, 0); +} + enum QueryStringWidgets { QUERY_STR_WIDGET_TEXT = 3, QUERY_STR_WIDGET_DEFAULT, @@ -1094,10 +1099,6 @@ virtual void OnClick(Point pt, int widget) { switch (widget) { - case QUERY_STR_WIDGET_TEXT: - ShowOnScreenKeyboard(this, QUERY_STR_WIDGET_TEXT, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK); - break; - case QUERY_STR_WIDGET_DEFAULT: this->text.buf[0] = '\0'; /* Fallthrough */ @@ -1131,6 +1132,11 @@ return state; } + virtual void OnOpenOSKWindow(int wid) + { + ShowOnScreenKeyboard(this, wid, QUERY_STR_WIDGET_CANCEL, QUERY_STR_WIDGET_OK); + } + ~QueryStringWindow() { if (!this->handled && this->parent != NULL) { @@ -1595,10 +1601,6 @@ break; } - case 10: // edit box - ShowOnScreenKeyboard(this, widget, 0, 0); - break; - case 11: case 12: // Delete, Save game break; } Index: src/network/network_chat_gui.cpp =================================================================== --- src/network/network_chat_gui.cpp (revision 14512) +++ src/network/network_chat_gui.cpp (working copy) @@ -443,10 +443,6 @@ virtual void OnClick(Point pt, int widget) { switch (widget) { - case 2: - ShowOnScreenKeyboard(this, 2, 0, 3); - break; - case 3: /* Send */ SendChat(this->text.buf, this->dtype, this->dest); /* FALLTHROUGH */ @@ -480,6 +476,11 @@ } return state; } + + virtual void OnOpenOSKWindow(int wid) + { + ShowOnScreenKeyboard(this, wid, 0, 3); + } }; static const Widget _chat_window_widgets[] = { Index: src/network/network_gui.cpp =================================================================== --- src/network/network_gui.cpp (revision 14512) +++ src/network/network_gui.cpp (working copy) @@ -446,10 +446,6 @@ { this->field = widget; switch (widget) { - case NGWW_CLIENT: - ShowOnScreenKeyboard(this, NGWW_CLIENT, 0, 0); - break; - case NGWW_CANCEL: // Cancel button DeleteWindowById(WC_NETWORK_WINDOW, 0); break; @@ -827,10 +823,6 @@ ShowNetworkGameWindow(); break; - case NSSW_GAMENAME: - ShowOnScreenKeyboard(this, NSSW_GAMENAME, 0, 0); - break; - case NSSW_SETPWD: // Set password button this->widget_id = NSSW_SETPWD; SetDParamStr(0, _settings_client.network.server_password); @@ -1800,10 +1792,6 @@ this->ToggleWidgetLoweredState(NCPWW_SAVE_AS_DEFAULT_PASSWORD); this->SetDirty(); break; - - case NCPWW_PASSWORD: - ShowOnScreenKeyboard(this, NCPWW_PASSWORD, 2, 1); - break; } } @@ -1826,6 +1814,11 @@ } return state; } + + virtual void OnOpenOSKWindow(int wid) + { + ShowOnScreenKeyboard(this, wid, 2, 1); + } }; static const Widget _ncp_window_widgets[] = { Index: src/querystring_gui.h =================================================================== --- src/querystring_gui.h (revision 14512) +++ src/querystring_gui.h (working copy) @@ -42,10 +42,13 @@ char *edit_str_buf; char *orig_str_buf; const uint16 edit_str_size; + int osk_ok, osk_cancel; QueryStringBaseWindow(uint16 size, const WindowDesc *desc, WindowNumber window_number = 0) : Window(desc, window_number), edit_str_size(size) { this->edit_str_buf = CallocT(size); + this->osk_ok = osk_ok; + this->osk_cancel = osk_cancel; } ~QueryStringBaseWindow() @@ -56,6 +59,7 @@ void DrawEditBox(int wid); void HandleEditBox(int wid); int HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state); + virtual void OnOpenOSKWindow(int wid); }; void ShowOnScreenKeyboard(QueryStringBaseWindow *parent, int button, int cancel, int ok); Index: src/signs_gui.cpp =================================================================== --- src/signs_gui.cpp (revision 14512) +++ src/signs_gui.cpp (working copy) @@ -285,10 +285,6 @@ break; } - case QUERY_EDIT_SIGN_WIDGET_TEXT: - ShowOnScreenKeyboard(this, widget, QUERY_EDIT_SIGN_WIDGET_CANCEL, QUERY_EDIT_SIGN_WIDGET_OK); - break; - case QUERY_EDIT_SIGN_WIDGET_DELETE: /* Only need to set the buffer to null, the rest is handled as the OK button */ RenameSign(this->cur_sign, ""); @@ -324,6 +320,11 @@ { this->HandleEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT); } + + virtual void OnOpenOSKWindow(int wid) + { + ShowOnScreenKeyboard(this, wid, QUERY_EDIT_SIGN_WIDGET_CANCEL, QUERY_EDIT_SIGN_WIDGET_OK); + } }; static const Widget _query_sign_edit_widgets[] = { Index: src/window.cpp =================================================================== --- src/window.cpp (revision 14512) +++ src/window.cpp (working copy) @@ -24,6 +24,7 @@ #include "window_func.h" #include "tilehighlight_func.h" #include "network/network.h" +#include "querystring_gui.h" #include "table/sprites.h" @@ -184,6 +185,13 @@ } } else if (wi->type == WWT_SCROLLBAR || wi->type == WWT_SCROLL2BAR || wi->type == WWT_HSCROLLBAR) { ScrollbarClickHandler(w, wi, x, y); + } else if (wi->type == WWT_EDITBOX) { + /* Open the OSK window if clicked on an edit box */ + QueryStringBaseWindow *qs = dynamic_cast(w); + if (qs != NULL) { + const int widget_index = wi - w->widget; + qs->OnOpenOSKWindow(widget_index); + } } if (w->desc_flags & WDF_STD_BTN) { Index: src/window_gui.h =================================================================== --- src/window_gui.h (revision 14512) +++ src/window_gui.h (working copy) @@ -477,7 +477,7 @@ WWT_CLOSEBOX, ///< Close box (at top-left of a window) WWT_DROPDOWN, ///< Raised drop down list (regular) WWT_DROPDOWNIN, ///< Inset drop down list (used on game options only) - WWT_EDITBOX, ///< a textbox for typing (don't forget to call ShowOnScreenKeyboard() when clicked) + WWT_EDITBOX, ///< a textbox for typing WWT_LAST, ///< Last Item. use WIDGETS_END to fill up padding!! WWT_MASK = 0x1F,