public class MenuItem extends ListGridRecord implements HasClickHandlers
Menu
. Each MenuItem
can have a
title
, icon
, shortcut\n keys
, optional submenu
and various other
settings. Alternatively, a
MenuItem
can contain an arbitrary widget via embeddedComponent
.
To create a Menu, create a series of MenuItems and call Menu.setItems()
.
Alternatively, Menus support binding to a DataSource
.
As another option, here's a sample of a Menu in Component XML
:
<Menu> <items> <MenuItem title="item1" click="alert(1)"/> <MenuItem title="item2"/> </items> </Menu>
id
factoryCreated, factoryProperties
Constructor and Description |
---|
MenuItem() |
MenuItem(com.google.gwt.core.client.JavaScriptObject jsObj) |
MenuItem(java.lang.String title) |
MenuItem(java.lang.String title,
java.lang.String icon) |
MenuItem(java.lang.String title,
java.lang.String icon,
java.lang.String keyTitle) |
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addClickHandler(ClickHandler handler)
Add a click handler.
|
java.lang.Boolean |
getAutoDismiss()
Whether a click on this specific
menuItem automatically dismisses the menu. |
java.lang.Boolean |
getCanSelectParent()
A MenuItem that has a submenu normally cannot be selected, instead clicking or hitting Enter while keyboard focus is on
the item shows the submenu.
|
java.lang.Boolean |
getChecked()
If true, this item displays a standard checkmark image to the left of its title.
|
java.lang.String |
getDisabledIcon()
The filename for this item's custom icon when the item is disabled.
|
Canvas |
getEmbeddedComponent()
Arbitrary UI component that should appear in this MenuItem.
|
java.lang.String[] |
getEmbeddedComponentFields()
|
EmbeddedPosition |
getEmbeddedComponentPosition()
See
ListGridRecord.embeddedComponentPosition , except that when used in a menuItem , default behavior is EmbeddedPosition "expand". |
java.lang.Boolean |
getEnabled()
Affects the visual style and interactivity of the menu item.
|
AdvancedCriteria |
getEnableWhen()
Criteria to be evaluated to determine whether this MenuItem should be disabled.
|
java.lang.Boolean |
getFetchSubmenus()
If false, no submenus will be fetched for this MenuItem.
|
java.lang.String |
getIcon()
The filename for this item's custom icon.
|
int |
getIconHeight()
The height applied to this item's icon.
|
int |
getIconWidth()
The width applied to this item's icon.
|
java.lang.Boolean |
getIsSeparator()
When set to
true , this menu item shows a horizontal separator instead of the title text. |
java.lang.String |
getKeyTitle()
A string to display in the shortcut-key column for this item.
|
static MenuItem |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
java.lang.Boolean |
getShowIconOnlyInline()
When used in an
AdaptiveMenu , should this MenuItem show only it's icon when displayed inline? |
Menu |
getSubmenu()
Deprecated.
use
com.smartgwt.client.widgets.Menu#getSubmenu instead |
java.lang.String |
getTitle()
The text displayed for the menu item
|
MenuItem |
setAutoDismiss(java.lang.Boolean autoDismiss)
Whether a click on this specific
menuItem automatically dismisses the menu. |
MenuItem |
setCanSelectParent(java.lang.Boolean canSelectParent)
A MenuItem that has a submenu normally cannot be selected, instead clicking or hitting Enter while keyboard focus is on
the item shows the submenu.
|
MenuItem |
setChecked(java.lang.Boolean checked)
If true, this item displays a standard checkmark image to the left of its title.
|
void |
setCheckIfCondition(MenuItemIfFunction checkIf)
Contains the condition that will check or uncheck the curent menuItem.
|
MenuItem |
setDisabledIcon(java.lang.String disabledIcon)
The filename for this item's custom icon when the item is disabled.
|
void |
setDynamicIconFunction(MenuItemStringFunction handler)
Contains the condition that will change the curent items' icon when met.
|
void |
setDynamicTitleFunction(MenuItemStringFunction handler)
Contains the condition that will change the curent items' title when met.
|
MenuItem |
setEmbeddedComponent(Canvas embeddedComponent)
Arbitrary UI component that should appear in this MenuItem.
|
MenuItem |
setEmbeddedComponentFields(java.lang.String... embeddedComponentFields)
|
MenuItem |
setEmbeddedComponentPosition(EmbeddedPosition embeddedComponentPosition)
See
ListGridRecord.embeddedComponentPosition , except that when used in a menuItem , default behavior is EmbeddedPosition "expand". |
MenuItem |
setEnabled(java.lang.Boolean enabled)
Affects the visual style and interactivity of the menu item.
|
void |
setEnableIfCondition(MenuItemIfFunction enableIf)
Contains the condition that will enable or disable the curent menuItem.
|
MenuItem |
setEnableWhen(AdvancedCriteria enableWhen)
Criteria to be evaluated to determine whether this MenuItem should be disabled.
|
MenuItem |
setFetchSubmenus(java.lang.Boolean fetchSubmenus)
If false, no submenus will be fetched for this MenuItem.
|
MenuItem |
setIcon(java.lang.String icon)
The filename for this item's custom icon.
|
MenuItem |
setIconHeight(int iconHeight)
The height applied to this item's icon.
|
MenuItem |
setIconWidth(int iconWidth)
The width applied to this item's icon.
|
MenuItem |
setIsSeparator(java.lang.Boolean isSeparator)
When set to
true , this menu item shows a horizontal separator instead of the title text. |
void |
setKeys(KeyIdentifier... keys)
Shortcut key(s) to fire the menu item action.
|
MenuItem |
setKeyTitle(java.lang.String keyTitle)
A string to display in the shortcut-key column for this item.
|
MenuItem |
setShowIconOnlyInline(java.lang.Boolean showIconOnlyInline)
When used in an
AdaptiveMenu , should this MenuItem show only it's icon when displayed inline? |
MenuItem |
setSubmenu(Menu submenu)
A reference to another menu, to display as a submenu when the mouse cursor hovers over this menu item.
|
MenuItem |
setTitle(java.lang.String title)
The text displayed for the menu item
|
get_baseStyle, get_canEdit, get_canRemove, getBackgroundComponent, getCanAcceptDrop, getCanDrag, getCanExpand, getCanSelect, getCustomStyle, getDetailDS, getIncludeInSummary, getIsGridSummary, getIsGroupSummary, getLinkText, getShowRollOver, getSingleCellValue, set_baseStyle, set_canEdit, set_canRemove, setBackgroundComponent, setCanAcceptDrop, setCanDrag, setCanExpand, setCanSelect, setCustomStyle, setDetailDS, setIncludeInSummary, setIsGridSummary, setIsGroupSummary, setLinkText, setShowRollOver, setSingleCellValue
convertToRecordArray, copyAttributes, copyAttributesInto, getAttributeAsRecordArray, getAttributeAsRecordList, getPaletteDefaults, isARecord, toMap
getRef, getRef, internalSetID
applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, isFactoryCreated, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttributeAsJavaObject, setFactoryCreated
equals, getJsObj, hashCode, isCreated, setJavaScriptObject, setJsObj
public MenuItem()
public MenuItem(com.google.gwt.core.client.JavaScriptObject jsObj)
public MenuItem(java.lang.String title)
public MenuItem(java.lang.String title, java.lang.String icon)
public MenuItem(java.lang.String title, java.lang.String icon, java.lang.String keyTitle)
public static MenuItem getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public MenuItem setAutoDismiss(java.lang.Boolean autoDismiss)
menuItem
automatically dismisses the menu. See Menu.autoDismiss
.autoDismiss
- New autoDismiss value. Default value is nullMenuItem
instance, for chaining setter callspublic java.lang.Boolean getAutoDismiss()
menuItem
automatically dismisses the menu. See Menu.autoDismiss
.public MenuItem setCanSelectParent(java.lang.Boolean canSelectParent)
canSelectParent
- New canSelectParent value. Default value is nullMenuItem
instance, for chaining setter callspublic java.lang.Boolean getCanSelectParent()
public MenuItem setChecked(java.lang.Boolean checked)
Menu.checkmarkImage
. If you need to set this
state dynamically, use checkIf()
instead.
checked
- New checked value. Default value is nullMenuItem
instance, for chaining setter callspublic java.lang.Boolean getChecked()
Menu.checkmarkImage
. If you need to set this
state dynamically, use checkIf()
instead.
public MenuItem setDisabledIcon(java.lang.String disabledIcon)
checked
are both specified, only the icon specified by this
property will be displayed. The path to the loaded skin directory and the skinImgDir are prepended to this filename to
form the full URL. If you need to set this state dynamically, use dynamicIcon()
instead.
disabledIcon
- New disabledIcon value. Default value is nullMenuItem
instance, for chaining setter callspublic java.lang.String getDisabledIcon()
checked
are both specified, only the icon specified by this
property will be displayed. The path to the loaded skin directory and the skinImgDir are prepended to this filename to
form the full URL. If you need to set this state dynamically, use dynamicIcon()
instead.
public MenuItem setEmbeddedComponent(Canvas embeddedComponent)
ListGridRecord.embeddedComponent
for an overview
and options for controlling placement. When embeddedComponent
is used in a MenuItem certain default
behaviors apply:
autoDismiss
defaults to
false and clicks on embeddedComponents are not bubbled to the menuItem - if an interaction with an
embeddedComponent is expected to dismiss the menu, custom code should call menu.hide
or hideAllMenus
as appropriate, before proceeding embeddedComponentPosition
is "expand". embeddedComponentFields
to override ListGridRecord.showRollOver
were set to false) setEmbeddedComponent
in class ListGridRecord
embeddedComponent
- New embeddedComponent value. Default value is nullMenuItem
instance, for chaining setter callsAppearance overview and related methods
public Canvas getEmbeddedComponent()
ListGridRecord.embeddedComponent
for an overview
and options for controlling placement. When embeddedComponent
is used in a MenuItem certain default
behaviors apply:
autoDismiss
defaults to
false and clicks on embeddedComponents are not bubbled to the menuItem - if an interaction with an
embeddedComponent is expected to dismiss the menu, custom code should call menu.hide
or hideAllMenus
as appropriate, before proceeding embeddedComponentPosition
is "expand". embeddedComponentFields
to override ListGridRecord.showRollOver
were set to false) getEmbeddedComponent
in class ListGridRecord
Appearance overview and related methods
public MenuItem setEmbeddedComponentFields(java.lang.String... embeddedComponentFields)
ListGridRecord.embeddedComponentFields
. Default for a MenuItem is to cover the title and key fields, leaving the icon
and submenu fields visible.setEmbeddedComponentFields
in class ListGridRecord
embeddedComponentFields
- New embeddedComponentFields value. Default value is nullMenuItem
instance, for chaining setter callsAppearance overview and related methods
public java.lang.String[] getEmbeddedComponentFields()
ListGridRecord.embeddedComponentFields
. Default for a MenuItem is to cover the title and key fields, leaving the icon
and submenu fields visible.getEmbeddedComponentFields
in class ListGridRecord
Appearance overview and related methods
public MenuItem setEmbeddedComponentPosition(EmbeddedPosition embeddedComponentPosition)
ListGridRecord.embeddedComponentPosition
, except that when used in a menuItem
, default behavior is EmbeddedPosition
"expand".setEmbeddedComponentPosition
in class ListGridRecord
embeddedComponentPosition
- New embeddedComponentPosition value. Default value is nullMenuItem
instance, for chaining setter callsAppearance overview and related methods
public EmbeddedPosition getEmbeddedComponentPosition()
ListGridRecord.embeddedComponentPosition
, except that when used in a menuItem
, default behavior is EmbeddedPosition
"expand".getEmbeddedComponentPosition
in class ListGridRecord
Appearance overview and related methods
public MenuItem setEnabled(java.lang.Boolean enabled)
false
, the menu item will not
respond to mouse rollovers or clicks. If you need to set this state dynamically, use enableIf()
instead.
setEnabled
in class ListGridRecord
enabled
- New enabled value. Default value is trueMenuItem
instance, for chaining setter callspublic java.lang.Boolean getEnabled()
false
, the menu item will not
respond to mouse rollovers or clicks. If you need to set this state dynamically, use enableIf()
instead.
getEnabled
in class ListGridRecord
public MenuItem setEnableWhen(AdvancedCriteria enableWhen)
A basic criteria uses textMatchStyle:"exact". When specified in Component XML
this property allows shorthand formats
for defining
criteria.
enableWhen
- New enableWhen value. Default value is nullMenuItem
instance, for chaining setter callsRuleCriteria overview and related methods
public AdvancedCriteria getEnableWhen()
A basic criteria uses textMatchStyle:"exact". When specified in Component XML
this property allows shorthand formats
for defining
criteria.
RuleCriteria overview and related methods
public MenuItem setFetchSubmenus(java.lang.Boolean fetchSubmenus)
Menu.fetchSubmenus
.fetchSubmenus
- New fetchSubmenus value. Default value is trueMenuItem
instance, for chaining setter callspublic java.lang.Boolean getFetchSubmenus()
Menu.fetchSubmenus
.public MenuItem setIcon(java.lang.String icon)
checked
are both specified, only the icon specified by this
property will be displayed. The path to the loaded skin directory and the skinImgDir are prepended to this filename to
form the full URL. If this item is disabled, and disabledIcon
is set, then that icon will be used instead. If you need to set this state dynamically, use dynamicIcon()
instead.
icon
- New icon value. Default value is nullMenuItem
instance, for chaining setter callspublic java.lang.String getIcon()
checked
are both specified, only the icon specified by this
property will be displayed. The path to the loaded skin directory and the skinImgDir are prepended to this filename to
form the full URL. If this item is disabled, and disabledIcon
is set, then that icon will be used instead. If you need to set this state dynamically, use dynamicIcon()
instead.
public MenuItem setIconHeight(int iconHeight)
16
can be changed for all MenuItems by overriding
Menu.iconHeight
.iconHeight
- New iconHeight value. Default value is 16MenuItem
instance, for chaining setter callspublic int getIconHeight()
16
can be changed for all MenuItems by overriding
Menu.iconHeight
.public MenuItem setIconWidth(int iconWidth)
16
can be changed for all MenuItems by overriding
Menu.iconWidth
.iconWidth
- New iconWidth value. Default value is 16MenuItem
instance, for chaining setter callspublic int getIconWidth()
16
can be changed for all MenuItems by overriding
Menu.iconWidth
.public MenuItem setIsSeparator(java.lang.Boolean isSeparator)
true
, this menu item shows a horizontal separator instead of the title
text. Typically specified as the only property of a menu
item, since the separator will not respond to mouse events.setIsSeparator
in class ListGridRecord
isSeparator
- New isSeparator value. Default value is falseMenuItem
instance, for chaining setter callspublic java.lang.Boolean getIsSeparator()
true
, this menu item shows a horizontal separator instead of the title
text. Typically specified as the only property of a menu
item, since the separator will not respond to mouse events.getIsSeparator
in class ListGridRecord
public MenuItem setKeyTitle(java.lang.String keyTitle)
keys
will be used by default.keyTitle
- New keyTitle value. Default value is see belowMenuItem
instance, for chaining setter callspublic java.lang.String getKeyTitle()
keys
will be used by default.public MenuItem setShowIconOnlyInline(java.lang.Boolean showIconOnlyInline)
AdaptiveMenu
, should this MenuItem show only it's icon
when displayed inline?showIconOnlyInline
- New showIconOnlyInline value. Default value is nullMenuItem
instance, for chaining setter callspublic java.lang.Boolean getShowIconOnlyInline()
AdaptiveMenu
, should this MenuItem show only it's icon
when displayed inline?public MenuItem setSubmenu(Menu submenu)
submenu
- New submenu value. Default value is nullMenuItem
instance, for chaining setter callspublic MenuItem setTitle(java.lang.String title)
title
- New title value. Default value is nullMenuItem
instance, for chaining setter callsHTMLString
public java.lang.String getTitle()
HTMLString
public com.google.gwt.event.shared.HandlerRegistration addClickHandler(ClickHandler handler)
Executed when this menu item is clicked by the user. The click handler must be specified as a function or string of
script. Call com.smartgwt.client.widgets.menu.events.MenuItemClickEvent#cancel()
from within ClickHandler.onClick(com.smartgwt.client.widgets.menu.events.MenuItemClickEvent)
to suppress the Menu.itemClick()
handler if specified.
addClickHandler
in interface HasClickHandlers
handler
- the click handlerHandlerRegistration
used to remove this handlerpublic void setKeys(KeyIdentifier... keys)
KeyIdentifier
.
To apply multiple shortcut keys to this item, set this property to an array of such key identifiers.keys
- keys Default value is nullpublic void setEnableIfCondition(MenuItemIfFunction enableIf)
If you don't need to
set this state dynamically, use enabled
instead.
public void setCheckIfCondition(MenuItemIfFunction checkIf)
If you don't need to
set this state dynamically, use checked
instead.
public void setDynamicTitleFunction(MenuItemStringFunction handler)
If you don't need to set this state dynamically, use title
instead.
public void setDynamicIconFunction(MenuItemStringFunction handler)
If you don't need to set this state dynamically, use icon
instead.
@Deprecated public Menu getSubmenu()
com.smartgwt.client.widgets.Menu#getSubmenu
instead