mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +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:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user