From 2c7ae3c61bcd763cd1b5ef67acfb3188772091d2 Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 29 Aug 2023 15:29:17 +0200 Subject: [PATCH] libui: Propagate Container events only if they are in the child widget's rect --- libui/src/Container.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libui/src/Container.cpp b/libui/src/Container.cpp index d188a07f..d7f320db 100644 --- a/libui/src/Container.cpp +++ b/libui/src/Container.cpp @@ -26,7 +26,8 @@ namespace ui Result Container::handle_mouse_move(Point position) { - return m_widget->handle_mouse_move(position); + if (m_widget->rect().contains(position)) return m_widget->handle_mouse_move(position); + return ui::EventResult::DidNotHandle; } Result Container::handle_mouse_leave() @@ -36,12 +37,14 @@ namespace ui Result Container::handle_mouse_down(Point position, int buttons) { - return m_widget->handle_mouse_down(position, buttons); + if (m_widget->rect().contains(position)) return m_widget->handle_mouse_down(position, buttons); + return ui::EventResult::DidNotHandle; } Result Container::handle_mouse_up(Point position, int buttons) { - return m_widget->handle_mouse_up(position, buttons); + if (m_widget->rect().contains(position)) return m_widget->handle_mouse_up(position, buttons); + return ui::EventResult::DidNotHandle; } Result Container::draw(Canvas& canvas)