diff --git a/src/guiengine/screen_keyboard.cpp b/src/guiengine/screen_keyboard.cpp index a06bd5911..0a8230ce5 100644 --- a/src/guiengine/screen_keyboard.cpp +++ b/src/guiengine/screen_keyboard.cpp @@ -27,6 +27,10 @@ #include "states_screens/state_manager.hpp" #include "utils/log.hpp" +#ifdef ANDROID +#include "../../../lib/irrlicht/source/Irrlicht/CIrrDeviceAndroid.h" +#endif + #include #include @@ -407,3 +411,21 @@ bool ScreenKeyboard::onEscapePressed() } // onEscapePressed // ---------------------------------------------------------------------------- +/** A function that determines if screen keyboard should be activated + */ +bool ScreenKeyboard::shouldUseScreenKeyboard() +{ + bool use_screen_keyboard = UserConfigParams::m_screen_keyboard > 1; + + #ifdef ANDROID + if (UserConfigParams::m_screen_keyboard == 1) + { + int32_t keyboard = AConfiguration_getKeyboard( + global_android_app->config); + + use_screen_keyboard = (keyboard != ACONFIGURATION_KEYBOARD_QWERTY); + } + #endif + + return use_screen_keyboard; +} \ No newline at end of file diff --git a/src/guiengine/screen_keyboard.hpp b/src/guiengine/screen_keyboard.hpp index a1236ecf1..8f6006763 100644 --- a/src/guiengine/screen_keyboard.hpp +++ b/src/guiengine/screen_keyboard.hpp @@ -118,6 +118,8 @@ namespace GUIEngine /** Returns true if keyboard is created */ static bool isActive() {return m_screen_keyboard != NULL;} + static bool shouldUseScreenKeyboard(); + /** Override to be notified of updates */ virtual void onUpdate(float dt); diff --git a/src/guiengine/widgets/CGUIEditBox.cpp b/src/guiengine/widgets/CGUIEditBox.cpp index cd0fdbff8..f58314bd0 100644 --- a/src/guiengine/widgets/CGUIEditBox.cpp +++ b/src/guiengine/widgets/CGUIEditBox.cpp @@ -1291,7 +1291,7 @@ bool CGUIEditBox::processMouse(const SEvent& event) { return false; } - else if (shouldUseScreenKeyboard()) + else if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard()) { openScreenKeyboard(); return true; @@ -1754,24 +1754,6 @@ void CGUIEditBox::deserializeAttributes(io::IAttributes* in, io::SAttributeReadW // setOverrideFont(in->getAttributeAsFont("OverrideFont")); } - -bool CGUIEditBox::shouldUseScreenKeyboard() -{ - bool use_screen_keyboard = UserConfigParams::m_screen_keyboard > 1; - - #ifdef ANDROID - if (UserConfigParams::m_screen_keyboard == 1) - { - int32_t keyboard = AConfiguration_getKeyboard( - global_android_app->config); - - use_screen_keyboard = (keyboard != ACONFIGURATION_KEYBOARD_QWERTY); - } - #endif - - return use_screen_keyboard; -} - void CGUIEditBox::openScreenKeyboard() { if (GUIEngine::ScreenKeyboard::getCurrent() != NULL) diff --git a/src/guiengine/widgets/CGUIEditBox.hpp b/src/guiengine/widgets/CGUIEditBox.hpp index 80c00c4fa..0db5f3731 100644 --- a/src/guiengine/widgets/CGUIEditBox.hpp +++ b/src/guiengine/widgets/CGUIEditBox.hpp @@ -119,7 +119,6 @@ using namespace gui; virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; } virtual void setDrawBackground(bool) { } - bool shouldUseScreenKeyboard(); void openScreenKeyboard(); protected: diff --git a/src/guiengine/widgets/text_box_widget.cpp b/src/guiengine/widgets/text_box_widget.cpp index dc6850f0e..57d3d7185 100644 --- a/src/guiengine/widgets/text_box_widget.cpp +++ b/src/guiengine/widgets/text_box_widget.cpp @@ -200,7 +200,7 @@ void TextBoxWidget::setActive(bool active) EventPropagation TextBoxWidget::onActivationInput(const int playerID) { - if (((MyCGUIEditBox*)m_element)->shouldUseScreenKeyboard()) + if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard()) { ((MyCGUIEditBox*)m_element)->openScreenKeyboard(); } diff --git a/src/states_screens/options/user_screen.cpp b/src/states_screens/options/user_screen.cpp index f15633418..87240da0a 100644 --- a/src/states_screens/options/user_screen.cpp +++ b/src/states_screens/options/user_screen.cpp @@ -22,6 +22,7 @@ #include "challenges/unlock_manager.hpp" #include "config/player_manager.hpp" #include "config/user_config.hpp" +#include "guiengine/screen_keyboard.hpp" #include "guiengine/widgets/check_box_widget.hpp" #include "guiengine/widgets/dynamic_ribbon_widget.hpp" #include "guiengine/widgets/label_widget.hpp" @@ -192,7 +193,7 @@ EventPropagation BaseUserScreen::filterActions(PlayerAction action, Input::InputType type, int playerId) { - if (action == PA_MENU_SELECT) + if (action == PA_MENU_SELECT && !ScreenKeyboard::shouldUseScreenKeyboard()) { if ((m_username_tb != NULL && m_username_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER)) || (m_password_tb != NULL && m_password_tb->isFocusedForPlayer(PLAYER_ID_GAME_MASTER)))