mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +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:
parent
4c6f541d5b
commit
7d0b59cb05
2 changed files with 21 additions and 0 deletions
|
@ -278,4 +278,20 @@ void Application::notify_drag_cancelled(Badge<WindowServerConnection>)
|
||||||
set_drag_hovered_widget_impl(nullptr);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,9 +95,14 @@ public:
|
||||||
}
|
}
|
||||||
void notify_drag_cancelled(Badge<WindowServerConnection>);
|
void notify_drag_cancelled(Badge<WindowServerConnection>);
|
||||||
|
|
||||||
|
Function<void(Action&)> on_action_enter;
|
||||||
|
Function<void(Action&)> on_action_leave;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Application(int argc, char** argv);
|
Application(int argc, char** argv);
|
||||||
|
|
||||||
|
virtual void event(Core::Event&) override;
|
||||||
|
|
||||||
void tooltip_show_timer_did_fire();
|
void tooltip_show_timer_did_fire();
|
||||||
void tooltip_hide_timer_did_fire();
|
void tooltip_hide_timer_did_fire();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue