mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 21:27:36 +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:
parent
fc4e01a3c9
commit
1c1ab71692
6 changed files with 44 additions and 20 deletions
|
@ -201,6 +201,8 @@ OwnPtr<Messages::WindowServer::AddMenuItemResponse> ClientConnection::handle(con
|
|||
}
|
||||
auto& menu = *(*it).value;
|
||||
auto menu_item = make<MenuItem>(menu, identifier, message.text(), message.shortcut(), message.enabled(), message.checkable(), message.checked());
|
||||
if (message.is_default())
|
||||
menu_item->set_default(true);
|
||||
if (message.icon_buffer_id() != -1) {
|
||||
auto icon_buffer = SharedBuffer::create_from_shbuf_id(message.icon_buffer_id());
|
||||
if (!icon_buffer)
|
||||
|
@ -260,6 +262,7 @@ OwnPtr<Messages::WindowServer::UpdateMenuItemResponse> ClientConnection::handle(
|
|||
menu_item->set_shortcut_text(message.shortcut());
|
||||
menu_item->set_enabled(message.enabled());
|
||||
menu_item->set_checkable(message.checkable());
|
||||
menu_item->set_default(message.is_default());
|
||||
if (message.checkable())
|
||||
menu_item->set_checked(message.checked());
|
||||
return make<Messages::WindowServer::UpdateMenuItemResponse>();
|
||||
|
|
|
@ -21,13 +21,14 @@ endpoint WindowServer = 2
|
|||
bool enabled,
|
||||
bool checkable,
|
||||
bool checked,
|
||||
bool is_default,
|
||||
[UTF8] String shortcut,
|
||||
i32 icon_buffer_id,
|
||||
bool exclusive) => ()
|
||||
|
||||
AddMenuSeparator(i32 menu_id) => ()
|
||||
|
||||
UpdateMenuItem(i32 menu_id, i32 identifier, i32 submenu_id, [UTF8] String text, bool enabled, bool checkable, bool checked, [UTF8] String shortcut) => ()
|
||||
UpdateMenuItem(i32 menu_id, i32 identifier, i32 submenu_id, [UTF8] String text, bool enabled, bool checkable, bool checked, bool is_default, [UTF8] String shortcut) => ()
|
||||
|
||||
CreateWindow(
|
||||
Gfx::IntRect rect,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue