Mobile: fix spurious double-taps (#38)
This commit is contained in:
parent
225c5ea912
commit
e03170fb77
@ -186,10 +186,10 @@ static bool isChild(gui::IGUIElement *tocheck, gui::IGUIElement *parent)
|
|||||||
|
|
||||||
#ifdef HAVE_TOUCHSCREENGUI
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
|
|
||||||
bool GUIModalMenu::simulateMouseEvent(
|
bool GUIModalMenu::convertToMouseEvent(
|
||||||
gui::IGUIElement *target, ETOUCH_INPUT_EVENT touch_event)
|
SEvent &mouse_event, ETOUCH_INPUT_EVENT touch_event) const noexcept
|
||||||
{
|
{
|
||||||
SEvent mouse_event{}; // value-initialized, not unitialized
|
mouse_event = {};
|
||||||
mouse_event.EventType = EET_MOUSE_INPUT_EVENT;
|
mouse_event.EventType = EET_MOUSE_INPUT_EVENT;
|
||||||
mouse_event.MouseInput.X = m_pointer.X;
|
mouse_event.MouseInput.X = m_pointer.X;
|
||||||
mouse_event.MouseInput.Y = m_pointer.Y;
|
mouse_event.MouseInput.Y = m_pointer.Y;
|
||||||
@ -209,11 +209,7 @@ bool GUIModalMenu::simulateMouseEvent(
|
|||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (preprocessEvent(mouse_event))
|
return true;
|
||||||
return true;
|
|
||||||
if (!target)
|
|
||||||
return false;
|
|
||||||
return target->OnEvent(mouse_event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIModalMenu::enter(gui::IGUIElement *hovered)
|
void GUIModalMenu::enter(gui::IGUIElement *hovered)
|
||||||
@ -311,9 +307,14 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
|
|||||||
enter(hovered);
|
enter(hovered);
|
||||||
}
|
}
|
||||||
gui::IGUIElement *focused = Environment->getFocus();
|
gui::IGUIElement *focused = Environment->getFocus();
|
||||||
bool ret = simulateMouseEvent(focused, event.TouchInput.Event);
|
SEvent mouse_event;
|
||||||
if (!ret && m_hovered != focused)
|
if (!convertToMouseEvent(mouse_event, event.TouchInput.Event))
|
||||||
ret = simulateMouseEvent(m_hovered.get(), event.TouchInput.Event);
|
return false;
|
||||||
|
bool ret = preprocessEvent(mouse_event);
|
||||||
|
if (!ret && focused)
|
||||||
|
ret = focused->OnEvent(mouse_event);
|
||||||
|
if (!ret && m_hovered && m_hovered != focused)
|
||||||
|
ret = m_hovered->OnEvent(mouse_event);
|
||||||
if (event.TouchInput.Event == ETIE_LEFT_UP)
|
if (event.TouchInput.Event == ETIE_LEFT_UP)
|
||||||
leave();
|
leave();
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -105,7 +105,7 @@ private:
|
|||||||
#ifdef HAVE_TOUCHSCREENGUI
|
#ifdef HAVE_TOUCHSCREENGUI
|
||||||
irr_ptr<gui::IGUIElement> m_hovered;
|
irr_ptr<gui::IGUIElement> m_hovered;
|
||||||
|
|
||||||
bool simulateMouseEvent(gui::IGUIElement *target, ETOUCH_INPUT_EVENT touch_event);
|
bool convertToMouseEvent(SEvent &mouse_event, ETOUCH_INPUT_EVENT touch_event) const noexcept;
|
||||||
void enter(gui::IGUIElement *element);
|
void enter(gui::IGUIElement *element);
|
||||||
void leave();
|
void leave();
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user