diff --git a/src/states_screens/register_screen.cpp b/src/states_screens/register_screen.cpp index 618011e50..7d2d7889e 100644 --- a/src/states_screens/register_screen.cpp +++ b/src/states_screens/register_screen.cpp @@ -137,6 +137,19 @@ void RegisterScreen::onDialogClose() makeEntryFieldsVisible(); } // onDialogClose +// ----------------------------------------------------------------------------- +void RegisterScreen::onFocusChanged(GUIEngine::Widget* previous, + GUIEngine::Widget* focus, int playerID) +{ + TextBoxWidget *online_name = getWidget("username"); + if (focus == online_name) + { + TextBoxWidget *local_name = getWidget("local_username"); + if (online_name->getText() == "") + online_name->setText(local_name->getText()); + } +} // onFocusChanged + // ----------------------------------------------------------------------------- /** Shows or hides the entry fields for online registration, depending on * online mode. diff --git a/src/states_screens/register_screen.hpp b/src/states_screens/register_screen.hpp index 4a5f48bd7..1ba2d770c 100644 --- a/src/states_screens/register_screen.hpp +++ b/src/states_screens/register_screen.hpp @@ -78,7 +78,10 @@ public: virtual void loadedFromFile() OVERRIDE {}; virtual void onUpdate(float dt) OVERRIDE; virtual bool onEscapePressed() OVERRIDE; - virtual void onDialogClose() OVERRIDE; + virtual void onDialogClose() OVERRIDE; + virtual void onFocusChanged(GUIEngine::Widget *previous, + GUIEngine::Widget *focus, + int playerID); void setRename(PlayerProfile *player); void acceptTerms();