1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:38:10 +00:00

LibGUI: Add action enter/leave hooks on GUI::Application

Apps can now hook into these events by assigning a callback to the
on_action_enter and on_action_leave hooks on GUI::Application. :^)
This commit is contained in:
Andreas Kling 2021-04-17 18:21:15 +02:00
parent 4c6f541d5b
commit 7d0b59cb05
2 changed files with 21 additions and 0 deletions

View file

@ -278,4 +278,20 @@ void Application::notify_drag_cancelled(Badge<WindowServerConnection>)
set_drag_hovered_widget_impl(nullptr);
}
void Application::event(Core::Event& event)
{
if (event.type() == GUI::Event::ActionEnter || event.type() == GUI::Event::ActionLeave) {
auto& action_event = static_cast<ActionEvent&>(event);
auto& action = action_event.action();
if (action_event.type() == GUI::Event::ActionEnter) {
if (on_action_enter)
on_action_enter(action);
} else {
if (on_action_leave)
on_action_leave(action);
}
}
Object::event(event);
}
}