mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
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. :^)
This commit is contained in:
parent
7d0b59cb05
commit
3bf2f7a329
Notes:
sideshowbarker
2024-07-18 19:30:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/3bf2f7a329c
1 changed files with 19 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -26,8 +26,10 @@
|
|||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/ActionGroup.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/Button.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
@ -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>(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>(ActionEvent::Type::ActionLeave, *action()));
|
||||
return Button::leave_event(event);
|
||||
}
|
||||
};
|
||||
|
||||
void Toolbar::add_action(Action& action)
|
||||
|
|
Loading…
Add table
Reference in a new issue