Index: src/misc_gui.cpp =================================================================== --- src/misc_gui.cpp (revision 18684) +++ src/misc_gui.cpp (working copy) @@ -1284,7 +1284,13 @@ HandleEditBoxResult QueryStringBaseWindow::HandleEditBoxKey(int wid, uint16 key, uint16 keycode, EventState &state) { - return this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state); + HandleEditBoxResult result = this->QueryString::HandleEditBoxKey(this, wid, key, keycode, state); + + if (result == HEBR_CANCEL) { + this->UnfocusFocusedWidget(); + } + + return result; } void QueryStringBaseWindow::HandleEditBox(int wid) Index: src/town_gui.cpp =================================================================== --- src/town_gui.cpp (revision 18684) +++ src/town_gui.cpp (working copy) @@ -1136,9 +1136,7 @@ virtual EventState OnKeyPress(uint16 key, uint16 keycode) { EventState state; - if (this->HandleEditBoxKey(TSEW_TOWNNAME_EDITBOX, key, keycode, state) == HEBR_CANCEL) { - this->UnfocusFocusedWidget(); - } + this->HandleEditBoxKey(TSEW_TOWNNAME_EDITBOX, key, keycode, state); return state; }