mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 14:25:08 +00:00
LibGUI+WindowServer: Add support for per-GWidget context menus.
You can now simply assign a GMenu as a GWidget's context menu and it will automagically pop up on right click. :^)
This commit is contained in:
parent
8feecf6c77
commit
c06a3bdeb4
12 changed files with 102 additions and 8 deletions
|
@ -39,6 +39,17 @@ void GMenu::add_separator()
|
|||
m_items.append(make<GMenuItem>(m_menu_id, GMenuItem::Separator));
|
||||
}
|
||||
|
||||
void GMenu::popup(const Point& screen_position)
|
||||
{
|
||||
if (!m_menu_id)
|
||||
realize_menu();
|
||||
WSAPI_ClientMessage request;
|
||||
request.type = WSAPI_ClientMessage::Type::PopupMenu;
|
||||
request.menu.menu_id = m_menu_id;
|
||||
request.menu.position = screen_position;
|
||||
GEventLoop::post_message_to_server(request);
|
||||
}
|
||||
|
||||
int GMenu::realize_menu()
|
||||
{
|
||||
WSAPI_ClientMessage request;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue