Allow to change cursor position in text box when screen keyboard is active

This commit is contained in:
Deve 2019-02-13 21:34:31 +01:00
parent 71c5c3988c
commit 415bfb491e
2 changed files with 47 additions and 39 deletions

View File

@ -362,6 +362,13 @@ bool ScreenKeyboard::onEvent(const SEvent &event)
if (event.EventType == EET_MOUSE_INPUT_EVENT)
{
core::position2d<s32> point(event.MouseInput.X, event.MouseInput.Y);
if (m_edit_box->isPointInside(point))
{
m_edit_box->OnEvent(event);
}
else
{
bool is_point_inside = m_irrlicht_window->isPointInside(point);
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
@ -386,6 +393,7 @@ bool ScreenKeyboard::onEvent(const SEvent &event)
}
}
}
}
return false;
}

View File

@ -1259,6 +1259,10 @@ bool CGUIEditBox::processMouse(const SEvent& event)
calculateScrollPos();
return true;
}
else
{
MouseMarking = false;
}
break;
case irr::EMIE_MOUSE_MOVED:
{
@ -1303,10 +1307,10 @@ bool CGUIEditBox::processMouse(const SEvent& event)
{
return false;
}
else if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard())
if (GUIEngine::ScreenKeyboard::shouldUseScreenKeyboard())
{
openScreenKeyboard();
return true;
}
#ifdef ANDROID
else if (UserConfigParams::m_screen_keyboard == 3)
@ -1319,8 +1323,6 @@ bool CGUIEditBox::processMouse(const SEvent& event)
}
}
#endif
else
{
// move cursor
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
@ -1341,7 +1343,6 @@ bool CGUIEditBox::processMouse(const SEvent& event)
return true;
}
}
default:
break;
}
@ -1707,6 +1708,9 @@ void CGUIEditBox::calculateScrollPos()
//! set text markers
void CGUIEditBox::setTextMarkers(s32 begin, s32 end)
{
if (GUIEngine::ScreenKeyboard::isActive())
return;
if ( begin != MarkBegin || end != MarkEnd )
{
MarkBegin = begin;
@ -1785,10 +1789,6 @@ void CGUIEditBox::openScreenKeyboard()
if (GUIEngine::ScreenKeyboard::getCurrent() != NULL)
return;
CursorPos = Text.size();
setTextMarkers(CursorPos, CursorPos);
calculateScrollPos();
new GUIEngine::ScreenKeyboard(1.0f, 0.40f, this);
}