1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

WindowServer/LibGUI: Add default menu items and allow default action for context menu

By specifying an optional Action for Menu::popup an application
can specify what item should be displayed as a default item.
This commit is contained in:
Tom 2020-07-10 13:29:21 -06:00 committed by Andreas Kling
parent fc4e01a3c9
commit 1c1ab71692
6 changed files with 44 additions and 20 deletions

View file

@ -47,7 +47,7 @@ public:
~MenuItem();
Type type() const { return m_type; }
String text() const;
const Action* action() const { return m_action.ptr(); }
Action* action() { return m_action.ptr(); }
unsigned identifier() const { return m_identifier; }
@ -64,6 +64,9 @@ public:
bool is_enabled() const { return m_enabled; }
void set_enabled(bool);
bool is_default() const { return m_default; }
void set_default(bool);
void set_menu_id(Badge<Menu>, unsigned menu_id);
void set_identifier(Badge<Menu>, unsigned identifier);
@ -76,6 +79,7 @@ private:
bool m_enabled { true };
bool m_checkable { false };
bool m_checked { false };
bool m_default { false };
RefPtr<Action> m_action;
RefPtr<Menu> m_submenu;
};