diff --git a/src/guiengine/event_handler.cpp b/src/guiengine/event_handler.cpp index 9a4660f40..3cef86bb2 100644 --- a/src/guiengine/event_handler.cpp +++ b/src/guiengine/event_handler.cpp @@ -352,7 +352,7 @@ void EventHandler::processGUIAction(const PlayerAction action, case PA_FIRE: case PA_MENU_SELECT: - if (pressedDown && !isWithinATextBox()) + if (pressedDown) { Widget* w = GUIEngine::getFocusForPlayer(playerID); if (w == NULL) break; diff --git a/src/guiengine/widgets/CGUIEditBox.cpp b/src/guiengine/widgets/CGUIEditBox.cpp index c76712c09..cd0fdbff8 100644 --- a/src/guiengine/widgets/CGUIEditBox.cpp +++ b/src/guiengine/widgets/CGUIEditBox.cpp @@ -1286,34 +1286,14 @@ bool CGUIEditBox::processMouse(const SEvent& event) } else if (!m_rtl) { - 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 - if (!AbsoluteClippingRect.isPointInside( core::position2d(event.MouseInput.X, event.MouseInput.Y))) { return false; } - else if (use_screen_keyboard) + else if (shouldUseScreenKeyboard()) { - CursorPos = Text.size(); - setTextMarkers(CursorPos, CursorPos); - calculateScrollPos(); - - if (GUIEngine::ScreenKeyboard::getCurrent() == NULL) - { - new GUIEngine::ScreenKeyboard(0.98f, 0.30f, this); - } - + openScreenKeyboard(); return true; } else @@ -1774,3 +1754,33 @@ 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) + return; + + CursorPos = Text.size(); + setTextMarkers(CursorPos, CursorPos); + calculateScrollPos(); + + new GUIEngine::ScreenKeyboard(0.98f, 0.30f, this); +} + diff --git a/src/guiengine/widgets/CGUIEditBox.hpp b/src/guiengine/widgets/CGUIEditBox.hpp index 1586307ca..80c00c4fa 100644 --- a/src/guiengine/widgets/CGUIEditBox.hpp +++ b/src/guiengine/widgets/CGUIEditBox.hpp @@ -118,7 +118,10 @@ using namespace gui; virtual irr::gui::IGUIFont* getOverrideFont() const { return NULL; } virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; } virtual void setDrawBackground(bool) { } - + + bool shouldUseScreenKeyboard(); + void openScreenKeyboard(); + protected: //! Breaks the single text line. void breakText(); diff --git a/src/guiengine/widgets/text_box_widget.cpp b/src/guiengine/widgets/text_box_widget.cpp index 02d32c4ea..dc6850f0e 100644 --- a/src/guiengine/widgets/text_box_widget.cpp +++ b/src/guiengine/widgets/text_box_widget.cpp @@ -17,8 +17,8 @@ #include "guiengine/engine.hpp" #include "guiengine/modaldialog.hpp" +#include "guiengine/screen_keyboard.hpp" #include "guiengine/widgets/text_box_widget.hpp" - #include "guiengine/widgets/CGUIEditBox.hpp" #include "utils/ptr_vector.hpp" #include "utils/translation.hpp" @@ -197,3 +197,15 @@ void TextBoxWidget::setActive(bool active) } // setActive // ----------------------------------------------------------------------------- + +EventPropagation TextBoxWidget::onActivationInput(const int playerID) +{ + if (((MyCGUIEditBox*)m_element)->shouldUseScreenKeyboard()) + { + ((MyCGUIEditBox*)m_element)->openScreenKeyboard(); + } + + // The onWidgetActivated() wasn't used at all before, so always block + // event to avoid breaking something + return EVENT_BLOCK; +} diff --git a/src/guiengine/widgets/text_box_widget.hpp b/src/guiengine/widgets/text_box_widget.hpp index ab1410f83..54d462387 100644 --- a/src/guiengine/widgets/text_box_widget.hpp +++ b/src/guiengine/widgets/text_box_widget.hpp @@ -75,6 +75,8 @@ namespace GUIEngine /** Override method from base class Widget */ virtual void setActive(bool active=true); + + virtual EventPropagation onActivationInput(const int playerID); }; }