Allow to change cursor position in text box when screen keyboard is active
This commit is contained in:
parent
71c5c3988c
commit
415bfb491e
@ -362,27 +362,35 @@ bool ScreenKeyboard::onEvent(const SEvent &event)
|
||||
if (event.EventType == EET_MOUSE_INPUT_EVENT)
|
||||
{
|
||||
core::position2d<s32> point(event.MouseInput.X, event.MouseInput.Y);
|
||||
bool is_point_inside = m_irrlicht_window->isPointInside(point);
|
||||
|
||||
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
|
||||
if (m_edit_box->isPointInside(point))
|
||||
{
|
||||
if (!is_point_inside)
|
||||
{
|
||||
m_schedule_close = true;
|
||||
return true;
|
||||
}
|
||||
m_edit_box->OnEvent(event);
|
||||
}
|
||||
else if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
|
||||
else
|
||||
{
|
||||
if (!is_point_inside && m_schedule_close)
|
||||
bool is_point_inside = m_irrlicht_window->isPointInside(point);
|
||||
|
||||
if (event.MouseInput.Event == EMIE_LMOUSE_PRESSED_DOWN)
|
||||
{
|
||||
dismiss();
|
||||
return true;
|
||||
if (!is_point_inside)
|
||||
{
|
||||
m_schedule_close = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
else if (event.MouseInput.Event == EMIE_LMOUSE_LEFT_UP)
|
||||
{
|
||||
m_schedule_close = false;
|
||||
return false;
|
||||
if (!is_point_inside && m_schedule_close)
|
||||
{
|
||||
dismiss();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_schedule_close = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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,28 +1323,25 @@ bool CGUIEditBox::processMouse(const SEvent& event)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
// move cursor
|
||||
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
|
||||
// move cursor
|
||||
CursorPos = getCursorPos(event.MouseInput.X, event.MouseInput.Y);
|
||||
|
||||
#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_)
|
||||
if (UTF16_IS_SURROGATE_LO(Text[CursorPos]))
|
||||
{
|
||||
if (CursorPos > 0)
|
||||
--CursorPos;
|
||||
}
|
||||
#endif
|
||||
s32 newMarkBegin = MarkBegin;
|
||||
if (!MouseMarking)
|
||||
newMarkBegin = CursorPos;
|
||||
|
||||
MouseMarking = true;
|
||||
setTextMarkers( newMarkBegin, CursorPos);
|
||||
calculateScrollPos();
|
||||
|
||||
return true;
|
||||
if (UTF16_IS_SURROGATE_LO(Text[CursorPos]))
|
||||
{
|
||||
if (CursorPos > 0)
|
||||
--CursorPos;
|
||||
}
|
||||
#endif
|
||||
s32 newMarkBegin = MarkBegin;
|
||||
if (!MouseMarking)
|
||||
newMarkBegin = CursorPos;
|
||||
|
||||
MouseMarking = true;
|
||||
setTextMarkers( newMarkBegin, CursorPos);
|
||||
calculateScrollPos();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user