Fix navigation with hacker keyboard arrows

This commit is contained in:
Benau 2019-05-28 01:43:42 +08:00
parent 2744a24951
commit 677d984267

View File

@ -286,6 +286,7 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
} }
else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED) else if (event.GUIEvent.EventType == EGET_ELEMENT_FOCUSED)
{ {
MarkBegin = MarkEnd = CursorPos = (u32)Text.size();
#ifdef _IRR_COMPILE_WITH_X11_DEVICE_ #ifdef _IRR_COMPILE_WITH_X11_DEVICE_
if (irr_driver->getDevice()->getType() == irr::EIDT_X11) if (irr_driver->getDevice()->getType() == irr::EIDT_X11)
{ {
@ -296,13 +297,21 @@ bool CGUIEditBox::OnEvent(const SEvent& event)
} }
#endif #endif
#ifdef ANDROID #ifdef ANDROID
if (irr_driver->getDevice()->getType() == irr::EIDT_ANDROID) if (irr_driver->getDevice()->hasOnScreenKeyboard() &&
irr_driver->getDevice()->getType() == irr::EIDT_ANDROID)
{ {
// If user toggle with hacker keyboard with arrows, keep
// using only text from STKEditTex
m_from_android_edittext = true;
CIrrDeviceAndroid* dl = dynamic_cast<CIrrDeviceAndroid*>( CIrrDeviceAndroid* dl = dynamic_cast<CIrrDeviceAndroid*>(
irr_driver->getDevice()); irr_driver->getDevice());
dl->fromSTKEditBox(getID(), Text, MarkBegin, MarkEnd, m_type); dl->fromSTKEditBox(getID(), Text, MarkBegin, MarkEnd, m_type);
} }
else
#endif #endif
{
m_from_android_edittext = false;
}
} }
break; break;
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) #if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
@ -1176,8 +1185,7 @@ void CGUIEditBox::draw()
void CGUIEditBox::setText(const wchar_t* text) void CGUIEditBox::setText(const wchar_t* text)
{ {
Text = text; Text = text;
if (u32(CursorPos) > Text.size()) MarkBegin = MarkEnd = CursorPos = (u32)Text.size();
CursorPos = Text.size();
HScrollPos = 0; HScrollPos = 0;
breakText(); breakText();
#ifdef ANDROID #ifdef ANDROID