Class MenuItem
- All Implemented Interfaces:
HasHandlers,HasClickHandlers
- Direct Known Subclasses:
MenuItemSeparator
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>
-
Field Summary
Fields inherited from class com.smartgwt.client.core.RefDataClass
idFields inherited from class com.smartgwt.client.core.DataClass
factoryCreated, factoryProperties -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddClickHandler(ClickHandler handler) Add a click handler.Whether a click on this specificmenuItemautomatically dismisses the menu.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.If true, this item displays a standard checkmark image to the left of its title.The filename for this item's custom icon when the item is disabled.Arbitrary UI component that should appear in this MenuItem.String[]SeeListGridRecord.embeddedComponentPosition, except that when used in amenuItem, default behavior isEmbeddedPosition"expand".Affects the visual style and interactivity of the menu item.Criteria to be evaluated to determine whether this MenuItem should be disabled.If false, no submenus will be fetched for this MenuItem.DefaultMenu.itemHiddenPropertyfor menu items.getIcon()The filename for this item's custom icon.intThe height applied to this item's icon.intThe width applied to this item's icon.When set totrue, this menu item shows a horizontal separator instead of thetitletext.A string to display in the shortcut-key column for this item.static MenuItemgetOrCreateRef(JavaScriptObject jsObj) When used in anAdaptiveMenu, should this MenuItem show only it'siconwhen displayed inline?Deprecated.getTitle()The text displayed for the menu itemCriteria to be evaluated to determine whether this MenuItem should be visible.setAutoDismiss(Boolean autoDismiss) Whether a click on this specificmenuItemautomatically dismisses the menu.setCanSelectParent(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.setChecked(Boolean checked) If true, this item displays a standard checkmark image to the left of its title.voidsetCheckIfCondition(MenuItemIfFunction checkIf) Contains the condition that will check or uncheck the curent menuItem.setDisabledIcon(String disabledIcon) The filename for this item's custom icon when the item is disabled.voidContains the condition that will change the curent items' icon when met.voidContains the condition that will change the curent items' title when met.setEmbeddedComponent(Canvas embeddedComponent) Arbitrary UI component that should appear in this MenuItem.setEmbeddedComponentFields(String... embeddedComponentFields) setEmbeddedComponentPosition(EmbeddedPosition embeddedComponentPosition) SeeListGridRecord.embeddedComponentPosition, except that when used in amenuItem, default behavior isEmbeddedPosition"expand".setEnabled(Boolean enabled) Affects the visual style and interactivity of the menu item.voidsetEnableIfCondition(MenuItemIfFunction enableIf) Contains the condition that will enable or disable the curent menuItem.setEnableWhen(AdvancedCriteria enableWhen) Criteria to be evaluated to determine whether this MenuItem should be disabled.setFetchSubmenus(Boolean fetchSubmenus) If false, no submenus will be fetched for this MenuItem.DefaultMenu.itemHiddenPropertyfor menu items.The filename for this item's custom icon.setIconHeight(int iconHeight) The height applied to this item's icon.setIconWidth(int iconWidth) The width applied to this item's icon.setIsSeparator(Boolean isSeparator) When set totrue, this menu item shows a horizontal separator instead of thetitletext.voidsetKeys(KeyIdentifier... keys) Shortcut key(s) to fire the menu item action.setKeyTitle(String keyTitle) A string to display in the shortcut-key column for this item.setShowIconOnlyInline(Boolean showIconOnlyInline) When used in anAdaptiveMenu, should this MenuItem show only it'siconwhen displayed inline?setSubmenu(Menu submenu) A reference to another menu, to display as a submenu when the mouse cursor hovers over this menu item.The text displayed for the menu itemsetVisibleWhen(AdvancedCriteria visibleWhen) Criteria to be evaluated to determine whether this MenuItem should be visible.Methods inherited from class com.smartgwt.client.widgets.grid.ListGridRecord
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, setSingleCellValueMethods inherited from class com.smartgwt.client.data.Record
convertToRecordArray, copyAttributes, copyAttributesInto, getAttributeAsRecordArray, getAttributeAsRecordList, getPaletteDefaults, isARecord, toMapMethods inherited from class com.smartgwt.client.core.RefDataClass
getRef, getRef, internalSetIDMethods inherited from class com.smartgwt.client.core.DataClass
applyFactoryProperties, doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsElement, 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, setFactoryCreatedMethods inherited from class com.smartgwt.client.core.JsObject
equals, getJsObj, hashCode, isCreated, setJavaScriptObject, setJsObjMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Constructor Details
-
MenuItem
public MenuItem() -
MenuItem
-
MenuItem
-
MenuItem
-
MenuItem
-
-
Method Details
-
getOrCreateRef
-
setAutoDismiss
Whether a click on this specificmenuItemautomatically dismisses the menu. SeeMenu.autoDismiss.- Parameters:
autoDismiss- New autoDismiss value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls
-
getAutoDismiss
Whether a click on this specificmenuItemautomatically dismisses the menu. SeeMenu.autoDismiss.- Returns:
- Current autoDismiss value. Default value is null
-
setCanSelectParent
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. Setting canSelectParent:true allows a menu item with a submenu to be selected directly.- Parameters:
canSelectParent- New canSelectParent value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls
-
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. Setting canSelectParent:true allows a menu item with a submenu to be selected directly.- Returns:
- Current canSelectParent value. Default value is null
-
setChecked
If true, this item displays a standard checkmark image to the left of its title. You can set the checkmark image URL by settingMenu.checkmarkImage.If you need to set this state dynamically, use
checkIf()instead.- Parameters:
checked- New checked value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getChecked
If true, this item displays a standard checkmark image to the left of its title. You can set the checkmark image URL by settingMenu.checkmarkImage.If you need to set this state dynamically, use
checkIf()instead.- Returns:
- Current checked value. Default value is null
- See Also:
-
setDisabledIcon
The filename for this item's custom icon when the item is disabled. If both this property andcheckedare 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.- Parameters:
disabledIcon- New disabledIcon value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getDisabledIcon
The filename for this item's custom icon when the item is disabled. If both this property andcheckedare 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.- Returns:
- Current disabledIcon value. Default value is null
- See Also:
-
setEmbeddedComponent
Arbitrary UI component that should appear in this MenuItem. SeeListGridRecord.embeddedComponentfor an overview and options for controlling placement.When
embeddedComponentis used in a MenuItem certain default behaviors apply:-
autoDismissdefaults 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.hideorhideAllMenusas appropriate, before proceeding - the default behavior for
embeddedComponentPositionis "expand". - the
component is placed over the title and key fields by default - use
embeddedComponentFieldsto override - rollOver
styling is disabled by default (as though
ListGridRecord.showRollOverwere set to false)
- Overrides:
setEmbeddedComponentin classListGridRecord- Parameters:
embeddedComponent- New embeddedComponent value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
-
getEmbeddedComponent
Arbitrary UI component that should appear in this MenuItem. SeeListGridRecord.embeddedComponentfor an overview and options for controlling placement.When
embeddedComponentis used in a MenuItem certain default behaviors apply:-
autoDismissdefaults 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.hideorhideAllMenusas appropriate, before proceeding - the default behavior for
embeddedComponentPositionis "expand". - the
component is placed over the title and key fields by default - use
embeddedComponentFieldsto override - rollOver
styling is disabled by default (as though
ListGridRecord.showRollOverwere set to false)
- Overrides:
getEmbeddedComponentin classListGridRecord- Returns:
- Current embeddedComponent value. Default value is null
- See Also:
-
-
setEmbeddedComponentFields
SeeListGridRecord.embeddedComponentFields. Default for a MenuItem is to cover the title and key fields, leaving the icon and submenu fields visible.- Overrides:
setEmbeddedComponentFieldsin classListGridRecord- Parameters:
embeddedComponentFields- New embeddedComponentFields value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getEmbeddedComponentFields
SeeListGridRecord.embeddedComponentFields. Default for a MenuItem is to cover the title and key fields, leaving the icon and submenu fields visible.- Overrides:
getEmbeddedComponentFieldsin classListGridRecord- Returns:
- Current embeddedComponentFields value. Default value is null
- See Also:
-
setEmbeddedComponentPosition
SeeListGridRecord.embeddedComponentPosition, except that when used in amenuItem, default behavior isEmbeddedPosition"expand".- Overrides:
setEmbeddedComponentPositionin classListGridRecord- Parameters:
embeddedComponentPosition- New embeddedComponentPosition value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getEmbeddedComponentPosition
SeeListGridRecord.embeddedComponentPosition, except that when used in amenuItem, default behavior isEmbeddedPosition"expand".- Overrides:
getEmbeddedComponentPositionin classListGridRecord- Returns:
- Current embeddedComponentPosition value. Default value is null
- See Also:
-
setEnabled
Affects the visual style and interactivity of the menu item. If set tofalse, the menu item will not respond to mouse rollovers or clicks.If you need to set this state dynamically, use
enableIf()instead.- Overrides:
setEnabledin classListGridRecord- Parameters:
enabled- New enabled value. Default value is true- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getEnabled
Affects the visual style and interactivity of the menu item. If set tofalse, the menu item will not respond to mouse rollovers or clicks.If you need to set this state dynamically, use
enableIf()instead.- Overrides:
getEnabledin classListGridRecord- Returns:
- Current enabled value. Default value is true
- See Also:
-
setEnableWhen
Criteria to be evaluated to determine whether this MenuItem should be disabled. Re-evaluated each time the menu is shown.A basic criteria uses textMatchStyle:"exact". When specified in
Component XMLthis property allowsshorthand formatsfor defining criteria.- Parameters:
enableWhen- New enableWhen value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getEnableWhen
Criteria to be evaluated to determine whether this MenuItem should be disabled. Re-evaluated each time the menu is shown.A basic criteria uses textMatchStyle:"exact". When specified in
Component XMLthis property allowsshorthand formatsfor defining criteria.- Returns:
- Current enableWhen value. Default value is null
- See Also:
-
setHidden
DefaultMenu.itemHiddenPropertyfor menu items. If true, this item will be hidden wihin the menu by default.To update item visibility at runtime, call
Menu.setItemHidden()- Parameters:
hidden- New hidden value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getHidden
DefaultMenu.itemHiddenPropertyfor menu items. If true, this item will be hidden wihin the menu by default.To update item visibility at runtime, call
Menu.setItemHidden()- Returns:
- Current hidden value. Default value is null
- See Also:
-
setIcon
The filename for this item's custom icon. If both this property andcheckedare 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, anddisabledIconis set, then that icon will be used instead.If you need to set this state dynamically, use
dynamicIcon()instead.- Parameters:
icon- New icon value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getIcon
The filename for this item's custom icon. If both this property andcheckedare 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, anddisabledIconis set, then that icon will be used instead.If you need to set this state dynamically, use
dynamicIcon()instead.- Returns:
- Current icon value. Default value is null
- See Also:
-
setIconHeight
The height applied to this item's icon. The default of16can be changed for all MenuItems by overridingMenu.iconHeight.- Parameters:
iconHeight- New iconHeight value. Default value is 16- Returns:
MenuIteminstance, for chaining setter calls
-
getIconHeight
public int getIconHeight()The height applied to this item's icon. The default of16can be changed for all MenuItems by overridingMenu.iconHeight.- Returns:
- Current iconHeight value. Default value is 16
-
setIconWidth
The width applied to this item's icon. The default of16can be changed for all MenuItems by overridingMenu.iconWidth.- Parameters:
iconWidth- New iconWidth value. Default value is 16- Returns:
MenuIteminstance, for chaining setter calls
-
getIconWidth
public int getIconWidth()The width applied to this item's icon. The default of16can be changed for all MenuItems by overridingMenu.iconWidth.- Returns:
- Current iconWidth value. Default value is 16
-
setIsSeparator
When set totrue, this menu item shows a horizontal separator instead of thetitletext. Typically specified as the only property of a menu item, since the separator will not respond to mouse events.- Overrides:
setIsSeparatorin classListGridRecord- Parameters:
isSeparator- New isSeparator value. Default value is false- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getIsSeparator
When set totrue, this menu item shows a horizontal separator instead of thetitletext. Typically specified as the only property of a menu item, since the separator will not respond to mouse events.- Overrides:
getIsSeparatorin classListGridRecord- Returns:
- Current isSeparator value. Default value is false
- See Also:
-
setKeyTitle
A string to display in the shortcut-key column for this item. If not specified, the first KeyName value inkeyswill be used by default.- Parameters:
keyTitle- New keyTitle value. Default value is see below- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getKeyTitle
A string to display in the shortcut-key column for this item. If not specified, the first KeyName value inkeyswill be used by default.- Returns:
- Current keyTitle value. Default value is see below
- See Also:
-
setShowIconOnlyInline
When used in anAdaptiveMenu, should this MenuItem show only it'siconwhen displayed inline?- Parameters:
showIconOnlyInline- New showIconOnlyInline value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls
-
getShowIconOnlyInline
When used in anAdaptiveMenu, should this MenuItem show only it'siconwhen displayed inline?- Returns:
- Current showIconOnlyInline value. Default value is null
-
setTitle
The text displayed for the menu item- Parameters:
title- New title value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getTitle
The text displayed for the menu item- Returns:
- Current title value. Default value is null
- See Also:
-
setVisibleWhen
Criteria to be evaluated to determine whether this MenuItem should be visible. Re-evaluated each time the menu is shown.A basic criteria uses textMatchStyle:"exact". When specified in
Component XMLthis property allowsshorthand formatsfor defining criteria.- Parameters:
visibleWhen- New visibleWhen value. Default value is null- Returns:
MenuIteminstance, for chaining setter calls- See Also:
-
getVisibleWhen
Criteria to be evaluated to determine whether this MenuItem should be visible. Re-evaluated each time the menu is shown.A basic criteria uses textMatchStyle:"exact". When specified in
Component XMLthis property allowsshorthand formatsfor defining criteria.- Returns:
- Current visibleWhen value. Default value is null
- See Also:
-
setKeys
Shortcut key(s) to fire the menu item action. Each key can be defined as aKeyIdentifier. To apply multiple shortcut keys to this item, set this property to an array of such key identifiers.- Parameters:
keys- keys Default value is null
-
com.smartgwt.client.widgets.Menu#getSubmenuinstead