eu.webtoolkit.jwt
Class WPopupMenuItem

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WWidget
          extended by eu.webtoolkit.jwt.WCompositeWidget
              extended by eu.webtoolkit.jwt.WPopupMenuItem

public class WPopupMenuItem
extends WCompositeWidget

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 Summary
WPopupMenuItem(java.lang.CharSequence text)
          Creates a new item with given text.
WPopupMenuItem(java.lang.String iconPath, java.lang.CharSequence text)
          Creates a new item with given icon and text.
 
Method Summary
 java.lang.Object getData()
          Returns additional data of the item.
 java.lang.String getIcon()
          Returns the item icon path.
 WLink getLink()
          Returns the associated link.
 AnchorTarget getLinkTarget()
          Returns the link target.
 WPopupMenu getPopupMenu()
          Returns the sub menu.
 WString getText()
          Returns the item text.
 boolean isCheckable()
          Returns whether the item is checkable.
 boolean isChecked()
          Returns the checked state.
 boolean isSelectable()
          Returns whether the menu item can be selected.
 void load()
          Loads content just before the widget is used.
 void remove()
          Destructor.
 void setCheckable(boolean checkable)
          Sets if the item is checkable.
 void setChecked(boolean checked)
          Sets the checked state.
 void setData(java.lang.Object data)
          Sets associated additional data with the item.
 void setDisabled(boolean disabled)
          Sets whether the widget is disabled.
 void setIcon(java.lang.String path)
          Sets the item icon path.
 void setLink(WLink link)
          Associates a link with the item.
 void setLinkTarget(AnchorTarget target)
          Sets the link target.
 void setPopupMenu(WPopupMenu menu)
          Sets a sub menu for the item.
 void setSelectable(boolean selectable)
          Sets whether the menu item can be selected.
 void setText(java.lang.CharSequence text)
          Sets the item text.
 Signal1<WPopupMenuItem> triggered()
          Signal emitted when an item is activated.
 
Methods inherited from class eu.webtoolkit.jwt.WCompositeWidget
addStyleClass, boxBorder, boxPadding, callJavaScriptMember, doJavaScript, enableAjax, find, getAttributeValue, getClearSides, getDecorationStyle, getFloatSide, getHeight, getId, getImplementation, getJavaScriptMember, getLineHeight, getMargin, getMaximumHeight, getMaximumWidth, getMinimumHeight, getMinimumWidth, getOffset, getPositionScheme, getStyleClass, getTabIndex, getToolTip, getVerticalAlignment, getVerticalAlignmentLength, getWidth, isDisabled, isEnabled, isHidden, isHiddenKeepsGeometry, isInline, isLoaded, isPopup, isVisible, propagateSetEnabled, refresh, removeStyleClass, resize, setAttributeValue, setClearSides, setDecorationStyle, setFloatSide, setHidden, setHiddenKeepsGeometry, setId, setImplementation, setInline, setJavaScriptMember, setLineHeight, setMargin, setMaximumSize, setMinimumSize, setOffsets, setPopup, setPositionScheme, setStyleClass, setTabIndex, setToolTip, setVerticalAlignment
 
Methods inherited from class eu.webtoolkit.jwt.WWidget
acceptDrops, acceptDrops, addCssRule, addCssRule, addStyleClass, animateHide, animateShow, containsExposed, disable, dropEvent, enable, getDrop, getJsRef, getParent, hide, htmlText, isLayoutSizeAware, isRendered, layoutSizeChanged, positionAt, positionAt, removeStyleClass, resize, setClearSides, setHeight, setHidden, setLayoutSizeAware, setMargin, setMargin, setMargin, setMargin, setMargin, setOffsets, setOffsets, setOffsets, setOffsets, setOffsets, setToolTip, setVerticalAlignment, setWidth, show, stopAcceptDrops, toggleStyleClass, toggleStyleClass, tr
 
Methods inherited from class eu.webtoolkit.jwt.WObject
addChild, getObjectName, setObjectName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WPopupMenuItem

public WPopupMenuItem(java.lang.CharSequence text)
Creates a new item with given text.

See Also:
WPopupMenu.addItem(CharSequence text)

WPopupMenuItem

public WPopupMenuItem(java.lang.String iconPath,
                      java.lang.CharSequence 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(String iconPath, CharSequence text)
Method Detail

remove

public void remove()
Destructor.

Overrides:
remove in class WCompositeWidget
See Also:
WContainerWidget.removeWidget(WWidget widget)

setText

public void setText(java.lang.CharSequence text)
Sets the item text.

See Also:
setIcon(String path)

getText

public WString getText()
Returns the item text.

See Also:
setText(CharSequence text)

setIcon

public void setIcon(java.lang.String path)
Sets the item icon path.

The icon should have a width of 16 pixels.

See Also:
setText(CharSequence text)

getIcon

public java.lang.String getIcon()
Returns the item icon path.

See Also:
setIcon(String path)

setCheckable

public void setCheckable(boolean 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(boolean checked), isChecked()

isCheckable

public boolean isCheckable()
Returns whether the item is checkable.

See Also:
setCheckable(boolean checkable)

setLink

public void setLink(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.


getLink

public WLink getLink()
Returns the associated link.

See Also:
setLink(WLink link)

setLinkTarget

public void setLinkTarget(AnchorTarget target)
Sets the link target.

See Also:
setLink(WLink link)

getLinkTarget

public AnchorTarget getLinkTarget()
Returns the link target.

See Also:
setLinkTarget(AnchorTarget target)

setPopupMenu

public void 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:
getPopupMenu()

getPopupMenu

public WPopupMenu getPopupMenu()
Returns the sub menu.

See Also:
setPopupMenu(WPopupMenu menu)

setChecked

public void setChecked(boolean checked)
Sets the checked state.

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

See Also:
setCheckable(boolean checkable), isCheckable()

isChecked

public boolean isChecked()
Returns the checked state.

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

See Also:
setChecked(boolean checked), isCheckable()

setSelectable

public void setSelectable(boolean selectable)
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.

Overrides:
setSelectable in class WCompositeWidget

isSelectable

public boolean isSelectable()
Returns whether the menu item can be selected.

See Also:
setSelectable(boolean selectable)

setData

public void setData(java.lang.Object data)
Sets associated additional data with the item.


getData

public java.lang.Object getData()
Returns additional data of the item.


triggered

public Signal1<WPopupMenuItem> triggered()
Signal emitted when an item is activated.

Returns this item as argument.

See Also:
WPopupMenu.triggered()

load

public void load()
Description copied from class: WWidget
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.

Overrides:
load in class WCompositeWidget

setDisabled

public void setDisabled(boolean disabled)
Description copied from class: WWidget
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.

Overrides:
setDisabled in class WCompositeWidget
See Also:
WWidget.disable(), WWidget.enable()