1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:47:34 +00:00

LibGUI: Add virtual handlers for WindowEntered and WindowLeft events

These can be useful if an application wants to react to the cursor
entering the window at any point, rather than just on a widget.
This commit is contained in:
sin-ack 2021-07-25 21:07:55 +00:00 committed by Ali Mohammad Pur
parent 6162e78c7f
commit 444ed56521
2 changed files with 24 additions and 3 deletions

View file

@ -572,10 +572,24 @@ void Window::handle_drag_move_event(DragEvent& event)
}
}
void Window::handle_left_event()
void Window::enter_event(Core::Event&)
{
}
void Window::leave_event(Core::Event&)
{
}
void Window::handle_entered_event(Core::Event& event)
{
enter_event(event);
}
void Window::handle_left_event(Core::Event& event)
{
set_hovered_widget(nullptr);
Application::the()->set_drag_hovered_widget({}, nullptr);
leave_event(event);
}
void Window::event(Core::Event& event)
@ -605,8 +619,11 @@ void Window::event(Core::Event& event)
if (event.type() == Event::WindowCloseRequest)
return handle_close_request();
if (event.type() == Event::WindowEntered)
return handle_entered_event(event);
if (event.type() == Event::WindowLeft)
return handle_left_event();
return handle_left_event(event);
if (event.type() == Event::Resize)
return handle_resize_event(static_cast<ResizeEvent&>(event));