Wt: Wt::Ext::Menu Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Wt::Ext::Menu Class Reference
Ext widgets (Wt::Ext, deprecated)

A menu presented in a popup window. More...

`#include <Wt/Ext/Menu>`

Inheritance diagram for Wt::Ext::Menu:
[legend]

List of all members.

## 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 F >
MenuItem * | addItem (const WString &text, const F &f)
| 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.
template<class F >
MenuItem * | addItem (const std::string &iconPath, const WString &text, const F &f)
| 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.

## Detailed Description

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

See also:
  MenuItem, AbstractButton::setMenu()

## Constructor & Destructor Documentation

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.

See also:
  Button::setMenu(), MenuItem::setMenu(), addMenu().

## Member Function Documentation

template<class T , class V >

MenuItem * Wt::Ext::Menu::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.

The target and method are connected to the MenuItem::activated() signal.

template<class F >

MenuItem * Wt::Ext::Menu::addItem | ( | const WString & | text,
|  | const F & | f
| ) |  |

Add an item with given text, and specify a slot method to be called when activated.

This variant of the overloaded singleShot() method supports a template function object (which supports operator ()).

template<class T , class V >

MenuItem * Wt::Ext::Menu::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.

The target and method are connected to the MenuItem::activated() signal.

template<class F >

MenuItem * Wt::Ext::Menu::addItem | ( | const std::string & | iconPath,
|  | const WString & | text,
|  | const F & | f
| ) |  |

Add an item with given text and icon, and specify a slot method to be called when activated.

This variant of the overloaded singleShot() method supports a template function object (which supports operator ()).

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator