Wt: Wt::WPopupMenuItem Class Reference

Wt 3.2.3

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

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Wt::WPopupMenuItem Class Reference

An item in a popup menu. More...

`#include <Wt/WPopupMenuItem>`

Inheritance diagram for Wt::WPopupMenuItem:
[legend]

List of all members.

## Public Member Functions
| WPopupMenuItem (const WString &text)
| Creates a new item with given text.
| WPopupMenuItem (const std::string &iconPath, const WString &text)
| Creates a new item with given icon and text.
| ~WPopupMenuItem ()
| Destructor.
void | setText (const WString &text)
| Sets the item text.
const WString & | text () const
| Returns the item text.
void | setIcon (const std::string &path)
| Sets the item icon path.
std::string | icon ()
| Returns the item icon path.
void | setCheckable (bool checkable)
| Sets if the item is checkable.
bool | isCheckable () const
| Returns whether the item is checkable.
void | setLink (const WLink &link)
| Associates a link with the item.
WLink | link () const
| Returns the associated link.
void | setLinkTarget (AnchorTarget target)
| Sets the link target.
AnchorTarget | linkTarget () const
| Returns the link target.
void | setPopupMenu (WPopupMenu *menu)
| Sets a sub menu for the item.
WPopupMenu * | popupMenu () const
| Returns the sub menu.
void | setChecked (bool checked)
| Sets the checked state.
bool | isChecked () const
| Returns the checked state.
void | setSelectable (bool selectable)
| Sets whether the menu item can be selected.
bool | isSelectable () const
| Returns whether the menu item can be selected.
void | setData (void *data)
| Sets associated additional data with the item.
void * | data () const
| Returns additional data of the item.
Signal< WPopupMenuItem * > & | triggered ()
| Signal emitted when an item is activated.
virtual void | load ()
| Loads content just before the widget is used.
virtual void | setDisabled (bool disabled)
| Sets whether the widget is disabled.

## Detailed Description

An item in a popup menu.

An item may have a text, icon, and can be checkable or lead to a submenu.

When the mouse hovers over the item, its class is changed from "Wt-item" to "Wt-selected".

See also:
  WPopupMenu

## Constructor & Destructor Documentation

Wt::WPopupMenuItem::WPopupMenuItem | ( | const WString & | text | ) |

Creates a new item with given text.

See also:
  WPopupMenu::addItem(const WString& text)

Wt::WPopupMenuItem::WPopupMenuItem | ( | const std::string & | iconPath,
|  | const WString & | text
| ) |  |

Creates a new item with given icon and text.

The icon is displayed left to the text.

Note:
  The icon should have a width of 16 pixels.

See also:
  WPopupMenu::addItem(const std::string& iconPath, const WString& text)

## Member Function Documentation

std::string Wt::WPopupMenuItem::icon | ( |  | ) |

Returns the item icon path.

See also:
  setIcon()

bool Wt::WPopupMenuItem::isCheckable | ( |  | ) | const

Returns whether the item is checkable.

See also:
  setCheckable()

bool Wt::WPopupMenuItem::isChecked | ( |  | ) | const

Returns the checked state.

This is only used when isCheckable() == `true`.

See also:
  setChecked(bool), isCheckable()

bool Wt::WPopupMenuItem::isSelectable | ( |  | ) | const

Returns whether the menu item can be selected.

See also:
  setSelectable()

WLink Wt::WPopupMenuItem::link | ( |  | ) | const

Returns the associated link.

See also:
  setLink()

AnchorTarget Wt::WPopupMenuItem::linkTarget | ( |  | ) | const

Returns the link target.

See also:
  setLinkTarget()

void Wt::WPopupMenuItem::load | ( |  | ) | `[virtual]`

Loads content just before the widget is used.

When the widget is inserted in the widget hierarchy, this method is called. Widgets that get inserted in the widget hierarchy will be rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground (or not for a plain HTML session). This method is called when the widget is directly or indirectly inserted into the widget tree.

The default implementation simply propagates the load signal to its children. You may want to override this method to delay loading of resource-intensive contents.

During the life-time of a widget, this method may be called multiple times, so you should make sure that you do a deferred initializiation only once.

Reimplemented from Wt::WCompositeWidget.

WPopupMenu* Wt::WPopupMenuItem::popupMenu | ( |  | ) | const

Returns the sub menu.

See also:
  setPopupMenu()

void Wt::WPopupMenuItem::setCheckable | ( | bool | checkable | ) |

Sets if the item is checkable.

When an item is checkable, a checkbox is displayed to the left of the item text (instead of an icon).

See also:
  setChecked(), isChecked()

void Wt::WPopupMenuItem::setChecked | ( | bool | checked | ) |

Sets the checked state.

This is only used when isCheckable() == `true`.

See also:
  setCheckable(bool), isCheckable()

void Wt::WPopupMenuItem::setDisabled | ( | bool | disabled | ) | `[virtual]`

Sets whether the widget is disabled.

Enables or disables the widget (including all its descendant widgets). setDisabled(false) will enable this widget and all descendant widgets that are not disabled. A widget is only enabled if it and all its ancestors in the widget tree are disabled.

Typically, a disabled form widget will not allow changing the value, and disabled widgets will not react to mouse click events.

See also:
  disable(), enable()

Reimplemented from Wt::WCompositeWidget.

void Wt::WPopupMenuItem::setIcon | ( | const std::string & | path | ) |

Sets the item icon path.

The icon should have a width of 16 pixels.

See also:
  setText()

void Wt::WPopupMenuItem::setLink | ( | const WLink & | link | ) |

Associates a link with the item.

You may turn the item into an anchor by specifying an link for it. The link may point to a URL, a resource, or an internal path.

The default link is a `null` link, which disables the anchor-like functionality.

void Wt::WPopupMenuItem::setLinkTarget | ( | AnchorTarget | target | ) |

Sets the link target.

See also:
  setLink()

void Wt::WPopupMenuItem::setPopupMenu | ( | WPopupMenu * | menu | ) |

Sets a sub menu for the item.

Sets a submenu for the item. Ownership of the submenu is transferred to the item.

See also:
  popupMenu()

void Wt::WPopupMenuItem::setSelectable | ( | bool | selectable | ) | `[virtual]`

Sets whether the menu item can be selected.

Only a menu item that can be selected can be the result of a popup menu selection.

The default value is `true` for a normal menu item, and `false` for a menu item that has a submenu.

An item that is selectable but is disabled can still not be selected.

Reimplemented from Wt::WCompositeWidget.

void Wt::WPopupMenuItem::setText | ( | const WString & | text | ) |

Sets the item text.

See also:
  setIcon()

const WString & Wt::WPopupMenuItem::text | ( |  | ) | const

Returns the item text.

See also:
  setText()

Signal<WPopupMenuItem *>& Wt::WPopupMenuItem::triggered | ( |  | ) |

Signal emitted when an item is activated.

Returns this item as argument.

See also:
  WPopupMenu::triggered()

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator