1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:38:10 +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:
Andreas Kling 2019-04-12 17:10:30 +02:00
parent 8feecf6c77
commit c06a3bdeb4
12 changed files with 102 additions and 8 deletions

View file

@ -178,4 +178,14 @@ WSMenuItem* WSMenu::item_at(const Point& position)
void WSMenu::close()
{
WSWindowManager::the().close_menu(*this);
};
if (menu_window())
menu_window()->set_visible(false);
}
void WSMenu::popup(const Point& position)
{
ASSERT(!is_empty());
auto& window = ensure_menu_window();
window.move_to(position);
window.set_visible(true);
}