From 3bf2f7a329ce41a053b9b7a202d18bbf9d135e76 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 17 Apr 2021 18:22:07 +0200 Subject: [PATCH] LibGUI: Make GUI::Toolbar buttons generate ActionEnter and ActionLeave Now you'll get the same event whether you hover an action in a menu or in a toolbar. :^) --- Userland/Libraries/LibGUI/Toolbar.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGUI/Toolbar.cpp b/Userland/Libraries/LibGUI/Toolbar.cpp index 0968b81b6d..a66ce9a22a 100644 --- a/Userland/Libraries/LibGUI/Toolbar.cpp +++ b/Userland/Libraries/LibGUI/Toolbar.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, Andreas Kling + * Copyright (c) 2018-2021, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,8 +26,10 @@ #include #include +#include #include #include +#include #include #include #include @@ -88,6 +90,22 @@ private: } return builder.to_string(); } + + virtual void enter_event(Core::Event& event) override + { + auto* app = Application::the(); + if (app && action()) + Core::EventLoop::current().post_event(*app, make(ActionEvent::Type::ActionEnter, *action())); + return Button::enter_event(event); + } + + virtual void leave_event(Core::Event& event) override + { + auto* app = Application::the(); + if (app && action()) + Core::EventLoop::current().post_event(*app, make(ActionEvent::Type::ActionLeave, *action())); + return Button::leave_event(event); + } }; void Toolbar::add_action(Action& action)