diff --git a/gframe/game.h b/gframe/game.h index 7dede5cba3..e2cab924ca 100644 --- a/gframe/game.h +++ b/gframe/game.h @@ -158,6 +158,12 @@ class Game { return focus && focus->hasType(type); } + void TrimText(irr::gui::IGUIElement* editbox) const { + irr::core::stringw text(editbox->getText()); + text.trim(); + editbox->setText(text.c_str()); + } + void OnResize(); recti Resize(s32 x, s32 y, s32 x2, s32 y2); recti Resize(s32 x, s32 y, s32 x2, s32 y2, s32 dx, s32 dy, s32 dx2, s32 dy2); diff --git a/gframe/menu_handler.cpp b/gframe/menu_handler.cpp index 25947a3594..3619a13053 100644 --- a/gframe/menu_handler.cpp +++ b/gframe/menu_handler.cpp @@ -62,6 +62,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) { } case BUTTON_JOIN_HOST: { bot_mode = false; + mainGame->TrimText(mainGame->ebJoinHost); + mainGame->TrimText(mainGame->ebJoinPort); char ip[20]; const wchar_t* pstr = mainGame->ebJoinHost->getText(); BufferIO::CopyWStr(pstr, ip, 16);