libui: Propagate Container events only if they are in the child widget's rect

This commit is contained in:
apio 2023-08-29 15:29:17 +02:00
parent f0f1a9c46c
commit 2c7ae3c61b
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -26,7 +26,8 @@ namespace ui
Result<EventResult> 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<EventResult> Container::handle_mouse_leave()
@ -36,12 +37,14 @@ namespace ui
Result<EventResult> 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<EventResult> 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<void> Container::draw(Canvas& canvas)