improve mouse events propagation

This commit is contained in:
2019-07-28 08:29:05 +02:00
parent ae5da7139c
commit 4ab35c6e9b
2 changed files with 14 additions and 3 deletions

View File

@@ -111,18 +111,19 @@ kEventResult Node::on_event(Event* e)
if (e->m_cat == kEventCategory::MouseEvent)
{
MouseEvent* me = static_cast<MouseEvent*>(e);
skip_children |= m_mouse_inside && !point_in_rect(me->m_pos, m_clip);
skip_children |= !m_mouse_inside && !point_in_rect(me->m_pos, m_clip);
}
skip_children |= (e->m_cat == kEventCategory::MouseEvent || e->m_cat == kEventCategory::GestureEvent) &&
(m_mouse_captured) && (root()->current_mouse_capture == this) && m_capture_children; // <-- THIS IS WRONG "!m_capture_children" is correct, but it breaks everything if changed
if (!m_display || glm::any(glm::lessThanEqual(zw(m_clip), { 0, 0 })))
return kEventResult::Available;
if (!skip_children)
{
auto children_copy = m_children; // make a copy for safety
// make a copy because any handler can change the children vector
auto children_copy = m_children;
for (auto it = children_copy.rbegin(); it != children_copy.rend(); ++it)
{
if ((*it)->on_event(e) == kEventResult::Consumed)