-
Notifications
You must be signed in to change notification settings - Fork 1
Menus
Semyon Gritsenko edited this page Aug 6, 2021
·
4 revisions
First of all call BaseComposite::createMainMenu it returns reference to menu that need to be modified.
You can add simple item to menu by calling Menu::addMenuItem with MenuItem class.
If you want to add a dropdown menu item, you need to follow these steps:
- Call BaseComposite::addPopupMenu
- Modify that popup menu from the previous step
- Call Menu::addMenuItem with DropDownMenuItem and set popupMenuHandle parameter with your popup menu handle
void createMenus(gui_framework::SeparateWindow* ptr)
{
using namespace gui_framework;
unique_ptr<Menu>& menu = ptr->createMainMenu(L"MainMenu");
menu->addMenuItem(make_unique<MenuItem>(L"First", []() { cout << "First" << endl; }));
Menu& popup = ptr->addPopupMenu(L"Second");
popup.addMenuItem(make_unique<MenuItem>(L"Inside", []() { cout << "Inside" << endl; }));
menu->addMenuItem(make_unique<DropDownMenuItem>(L"Popup", popup.getHandle()));
}