A menu presented in a popup window. More...
#include <Wt/Ext/Menu>
Inherits Wt::Ext::Widget.
Public Member Functions | |
Menu () | |
Create a new menu. | |
MenuItem * | addItem (const WString &text) |
Add an item with given text. | |
MenuItem * | addItem (const std::string &iconPath, const WString &text) |
Add an item with given icon and text. | |
template<class T , class V > | |
MenuItem * | addItem (const WString &text, T *target, void(V::*method)()) |
Add an item with given text, and specify a slot method to be called when activated. | |
template<class T , class V > | |
MenuItem * | addItem (const std::string &iconPath, const WString &text, T *target, void(V::*method)()) |
Add an item with given text and icon, and specify a slot method to be called when activated. | |
MenuItem * | addMenu (const WString &text, Menu *menu) |
Add a submenu, with given text. | |
MenuItem * | addMenu (const std::string &iconPath, const WString &text, Menu *menu) |
Add a submenu, with given icon and text. | |
void | add (MenuItem *item) |
Add a menu item. | |
void | add (WWidget *item) |
Add a widget to the menu. | |
void | addSeparator () |
Add a separator to the menu. |
A menu presented in a popup window.
A menu is always presented in a popup window, and, unlike other widgets, cannot be instantiated on its own (by adding to a WContainerWidget). Instead it must be associated with a Button or MenuItem (to create sub menus).
Usage example:
// Create a menu with some items Wt::Ext::Menu *menu = new Wt::Ext::Menu(); Wt::Ext::MenuItem *item; item = menu->addItem("File open..."); item->setIcon("icons/yellow-folder-open.png"); item = menu->addItem("I dig Wt"); item->setCheckable(true); item->setChecked(true); item = menu->addItem("I dig Wt too"); item->setCheckable(true); menu->addSeparator(); menu->addItem("Menu item"); menu->addSeparator(); // Add a sub menu Wt::Ext::Menu *subMenu = new Wt::Ext::Menu(); subMenu->addItem("Do this"); subMenu->addItem("And that"); item = menu->addMenu("More ...", subMenu); item->setIcon("icons/yellow-folder-open.png"); // Create a tool bar Wt::Ext::ToolBar *toolBar = new Wt::Ext::ToolBar(ex); // Associate the menu with a button Wt::Ext::Button *b = toolBar->addButton("Button w/Menu", menu); b->setIcon("icons/yellow-folder-closed.png");
Example of a Menu
Wt::Ext::Menu::Menu | ( | ) |
Create a new menu.
The menu cannot be added to a WContainerWidget, but must instead be associated with a Button or MenuItem.
MenuItem * Wt::Ext::Menu::addItem | ( | const std::string & | iconPath, | |
const WString & | text, | |||
T * | target, | |||
void(V::*)() | method | |||
) | [inline] |
Add an item with given text and icon, and specify a slot method to be called when activated.
The target and method are connected to the MenuItem::activated() signal.
MenuItem * Wt::Ext::Menu::addItem | ( | const WString & | text, | |
T * | target, | |||
void(V::*)() | method | |||
) | [inline] |
Add an item with given text, and specify a slot method to be called when activated.
The target and method are connected to the MenuItem::activated() signal.