Skip to main content

ContextMenu

#include "toolkit/context_menu.hpp"

A one-shot popup menu (right-click menu) built from a list of MenuItems. Unlike Menu, it isn't attached to a widget beforehand — construct it with its items and call show() at the click position.

ContextMenu screenshot

Example​

using toolkit::MenuItem;
auto menu = toolkit::ContextMenu({
MenuItem::action("Cut", [] { cut(); }),
MenuItem::action("Copy", [] { copy(); }),
MenuItem::action("Paste", [] { paste(); }),
});
menu.show(window, click_pos);

Construction​

explicit ContextMenu(std::vector<MenuItem> items);

API​

MemberDescription
show(Window *window, Point position)Display the popup at a window-relative position