LibGUI: Add Menu::set_children_actions_enabled() helper

This adds a helper function to Menu that allows us to set all the
children enabled/disabled.
This commit is contained in:
Marcus Nilsson 2022-01-09 00:28:05 +01:00 committed by Linus Groh
commit 708ec90bba
Notes: sideshowbarker 2024-07-17 21:18:16 +09:00
2 changed files with 10 additions and 0 deletions

View file

@ -164,6 +164,14 @@ Action* Menu::action_at(size_t index)
return m_items[index].action();
}
void Menu::set_children_actions_enabled(bool enabled)
{
for (auto& item : m_items) {
if (item.action())
item.action()->set_enabled(enabled);
}
}
void Menu::visibility_did_change(Badge<WindowServerConnection>, bool visible)
{
if (m_visible == visible)

View file

@ -45,6 +45,8 @@ public:
void visibility_did_change(Badge<WindowServerConnection>, bool visible);
void set_children_actions_enabled(bool enabled);
Function<void(bool)> on_visibility_change;
bool is_visible() const { return m_visible; }