Allow to activate screen keyboard using gamepad
This commit is contained in:
parent
91074705fd
commit
e585c26833
@ -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;
|
||||
|
@ -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<s32>(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);
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,9 @@ using namespace gui;
|
||||
virtual irr::gui::IGUIFont* getActiveFont() const { return NULL; }
|
||||
virtual void setDrawBackground(bool) { }
|
||||
|
||||
bool shouldUseScreenKeyboard();
|
||||
void openScreenKeyboard();
|
||||
|
||||
protected:
|
||||
//! Breaks the single text line.
|
||||
void breakText();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -75,6 +75,8 @@ namespace GUIEngine
|
||||
|
||||
/** Override method from base class Widget */
|
||||
virtual void setActive(bool active=true);
|
||||
|
||||
virtual EventPropagation onActivationInput(const int playerID);
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user