com.smartgwt.client.widgets.menu

## Class MenuItem

- java.lang.Object
- - com.smartgwt.client.core.JsObject
  - - com.smartgwt.client.core.DataClass
    - - com.smartgwt.client.core.RefDataClass
      - - com.smartgwt.client.data.Record
        - - com.smartgwt.client.widgets.grid.ListGridRecord
          - - com.smartgwt.client.widgets.menu.MenuItem

- All Implemented Interfaces:
    com.google.gwt.event.shared.HasHandlers, HasClickHandlers
  Direct Known Subclasses:
    MenuItemSeparator

      public class MenuItem
      extends ListGridRecord
      implements HasClickHandlers

  Menu items are specified are object literals, not class instances. For example, when developing in JavaScript, a typical initialization block for a Menu would look like this:

        Menu.create({
            data: [
                {title: "item1", click: "alert(1)"},
                {title: "item2"}
            ]
        });

  And in XML:

        <Menu>
           <data>
               <MenuItem title="item1" click="alert(1)"/>
               <MenuItem title="item2"/>
           </data>
        </Menu>

- - ### Field Summary

    - ### Fields inherited from class com.smartgwt.client.core.RefDataClass

      `id`

    - ### Fields inherited from class com.smartgwt.client.core.JsObject

      `jsObj`

  - ### Constructor Summary

    Constructors
    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)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `com.google.gwt.event.shared.HandlerRegistration` | `addClickHandler(ClickHandler handler)` Add a click handler.
    `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.
    `java.lang.Boolean` | `getEnabled()` Affects the visual style and interactivity of the menu item.
    `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)`
    `Menu` | `getSubmenu()` A reference to another menu, to display as a submenu when the mouse cursor hovers over this menu item.
    `java.lang.String` | `getTitle()` The text displayed for the menu item
    `void` | `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.
    `void` | `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.
    `void` | `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.
    `void` | `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.
    `void` | `setFetchSubmenus(java.lang.Boolean fetchSubmenus)` If false, no submenus will be fetched for this MenuItem.
    `void` | `setIcon(java.lang.String icon)` The filename for this item's custom icon.
    `void` | `setIconHeight(int iconHeight)` The height applied to this item's icon.
    `void` | `setIconWidth(int iconWidth)` The width applied to this item's icon.
    `void` | `setIsSeparator(java.lang.Boolean isSeparator)` When set to `true`, this menu item shows a horizontal separator instead of the `title` text.
    `void` | `setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)`
    `void` | `setKeys(KeyIdentifier... keys)` Shortcut key(s) to fire the menu item action.
    `void` | `setKeyTitle(java.lang.String keyTitle)` A string to display in the shortcut-key column for this item.
    `void` | `setSubmenu(Menu submenu)` A reference to another menu, to display as a submenu when the mouse cursor hovers over this menu item.
    `void` | `setTitle(java.lang.String title)` The text displayed for the menu item

    - ### 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, getSingleCellValue, set_baseStyle, set_canEdit, set_canRemove, setBackgroundComponent, setCanAcceptDrop, setCanDrag, setCanExpand, setCanSelect, setCustomStyle, setDetailDS, setIncludeInSummary, setIsGridSummary, setIsGroupSummary, setLinkText, setSingleCellValue`

    - ### Methods inherited from class com.smartgwt.client.data.Record

      `convertToRecordArray, copyAttributes, copyAttributesInto, getAttributeAsRecordArray, getAttributeAsRecordList, isARecord, toMap`

    - ### Methods inherited from class com.smartgwt.client.core.RefDataClass

      `getRef, getRef, internalSetID`

    - ### Methods inherited from class com.smartgwt.client.core.DataClass

      `doAddHandler, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsDoubleArray, getAttributeAsFloat, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsLong, getAttributeAsMap, getAttributeAsObject, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getAttributes, getHandlerCount, getJsObj, 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`

    - ### Methods inherited from class com.smartgwt.client.core.JsObject

      `equals, hashCode, isCreated, setJsObj`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.google.gwt.event.shared.HasHandlers

      `fireEvent`

- - ### Constructor Detail

    - #### MenuItem

          public MenuItem()

    - #### MenuItem

          public MenuItem(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### MenuItem

          public MenuItem(java.lang.String title)

    - #### MenuItem

          public MenuItem(java.lang.String title,
                  java.lang.String icon)

    - #### MenuItem

          public MenuItem(java.lang.String title,
                  java.lang.String icon,
                  java.lang.String keyTitle)

  - ### Method Detail

    - #### getOrCreateRef

          public static MenuItem getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

    - #### setJavaScriptObject

          public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)

      Overrides:
        `setJavaScriptObject` in class `ListGridRecord`

    - #### setCanSelectParent

          public void 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. Setting canSelectParent:true allows a menu item with a submenu to be selected directly.
      Parameters:
        `canSelectParent` - canSelectParent Default value is null

    - #### getCanSelectParent

          public 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. Setting canSelectParent:true allows a menu item with a submenu to be selected directly.
      Returns:
        Boolean

    - #### setChecked

          public void setChecked(java.lang.Boolean checked)

      If true, this item displays a standard checkmark image to the left of its title. You can set the checkmark image URL by setting `checkmarkImage`.

      If you need to set this state dynamically, use `MenuItem.checkIf` instead.

      Parameters:
        `checked` - checked Default value is null
      See Also:
        Appearance Example

    - #### getChecked

          public java.lang.Boolean getChecked()

      If true, this item displays a standard checkmark image to the left of its title. You can set the checkmark image URL by setting `checkmarkImage`.

      If you need to set this state dynamically, use `MenuItem.checkIf` instead.

      Returns:
        Boolean
      See Also:
        Appearance Example

    - #### setDisabledIcon

          public void setDisabledIcon(java.lang.String disabledIcon)

      The filename for this item's custom icon when the item is disabled. If both this property and `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 `MenuItem.dynamicIcon` instead.

      Parameters:
        `disabledIcon` - . See `String`. Default value is null
      See Also:
        Appearance Example

    - #### getDisabledIcon

          public java.lang.String getDisabledIcon()

      The filename for this item's custom icon when the item is disabled. If both this property and `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 `MenuItem.dynamicIcon` instead.

      Returns:
        . See `String`
      See Also:
        Appearance Example

    - #### setEnabled

          public void setEnabled(java.lang.Boolean enabled)

      Affects the visual style and interactivity of the menu item. If set to `false`, the menu item will not respond to mouse rollovers or clicks.

      If you need to set this state dynamically, use `MenuItem.enableIf` instead.

      Overrides:
        `setEnabled` in class `ListGridRecord`
      Parameters:
        `enabled` - enabled Default value is true
      See Also:
        Disabled rows Example

    - #### getEnabled

          public java.lang.Boolean getEnabled()

      Affects the visual style and interactivity of the menu item. If set to `false`, the menu item will not respond to mouse rollovers or clicks.

      If you need to set this state dynamically, use `MenuItem.enableIf` instead.

      Overrides:
        `getEnabled` in class `ListGridRecord`
      Returns:
        Boolean
      See Also:
        Disabled rows Example

    - #### setFetchSubmenus

          public void setFetchSubmenus(java.lang.Boolean fetchSubmenus)

      If false, no submenus will be fetched for this MenuItem. This can be set globally via `fetchSubmenus`.
      Parameters:
        `fetchSubmenus` - fetchSubmenus Default value is true

    - #### getFetchSubmenus

          public java.lang.Boolean getFetchSubmenus()

      If false, no submenus will be fetched for this MenuItem. This can be set globally via `fetchSubmenus`.
      Returns:
        Boolean

    - #### setIcon

          public void setIcon(java.lang.String icon)

      The filename for this item's custom icon. If both this property and `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 `MenuItem.dynamicIcon` instead.

      Parameters:
        `icon` - . See `String`. Default value is null
      See Also:
        Appearance Example

    - #### getIcon

          public java.lang.String getIcon()

      The filename for this item's custom icon. If both this property and `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 `MenuItem.dynamicIcon` instead.

      Returns:
        . See `String`
      See Also:
        Appearance Example

    - #### setIconHeight

          public void setIconHeight(int iconHeight)

      The height applied to this item's icon. The default of `16` can be changed for all MenuItems by overriding `iconHeight`.
      Parameters:
        `iconHeight` - iconHeight Default value is 16

    - #### getIconHeight

          public int getIconHeight()

      The height applied to this item's icon. The default of `16` can be changed for all MenuItems by overriding `iconHeight`.
      Returns:
        int

    - #### setIconWidth

          public void setIconWidth(int iconWidth)

      The width applied to this item's icon. The default of `16` can be changed for all MenuItems by overriding `iconWidth`.
      Parameters:
        `iconWidth` - iconWidth Default value is 16

    - #### getIconWidth

          public int getIconWidth()

      The width applied to this item's icon. The default of `16` can be changed for all MenuItems by overriding `iconWidth`.
      Returns:
        int

    - #### setIsSeparator

          public void setIsSeparator(java.lang.Boolean isSeparator)

      When set to `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.
      Overrides:
        `setIsSeparator` in class `ListGridRecord`
      Parameters:
        `isSeparator` - isSeparator Default value is false
      See Also:
        Appearance Example

    - #### getIsSeparator

          public java.lang.Boolean getIsSeparator()

      When set to `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.
      Overrides:
        `getIsSeparator` in class `ListGridRecord`
      Returns:
        Boolean
      See Also:
        Appearance Example

    - #### setKeyTitle

          public void setKeyTitle(java.lang.String keyTitle)

      A string to display in the shortcut-key column for this item. If not specified, the first KeyName value in `keys` will be used by default.
      Parameters:
        `keyTitle` - . See `String`. Default value is see below
      See Also:
        Appearance Example

    - #### getKeyTitle

          public java.lang.String getKeyTitle()

      A string to display in the shortcut-key column for this item. If not specified, the first KeyName value in `keys` will be used by default.
      Returns:
        . See `String`
      See Also:
        Appearance Example

    - #### setSubmenu

          public void setSubmenu(Menu submenu)

      A reference to another menu, to display as a submenu when the mouse cursor hovers over this menu item.
      Parameters:
        `submenu` - submenu Default value is null
      See Also:
        Appearance Example

    - #### getSubmenu

          public Menu getSubmenu()

      A reference to another menu, to display as a submenu when the mouse cursor hovers over this menu item.
      Returns:
        Menu
      See Also:
        Appearance Example

    - #### setTitle

          public void setTitle(java.lang.String title)

      The text displayed for the menu item
      Parameters:
        `title` - . See `String`. Default value is null

    - #### getTitle

          public java.lang.String getTitle()

      The text displayed for the menu item
      Returns:
        . See `String`

    - #### addClickHandler

          public com.google.gwt.event.shared.HandlerRegistration addClickHandler(ClickHandler handler)

      Add a click 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.events.ClickEvent)` to suppress the `Menu.itemClick` handler if specified.

      Specified by:
        `addClickHandler` in interface `HasClickHandlers`
      Parameters:
        `handler` - the click handler
      Returns:
        `HandlerRegistration` used to remove this handler

    - #### setKeys

          public void setKeys(KeyIdentifier... keys)

      Shortcut key(s) to fire the menu item action. Each key can be defined as a `KeyIdentifier`. 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

    - #### setEnableIfCondition

          public void setEnableIfCondition(MenuItemIfFunction enableIf)

      Contains the condition that will enable or disable the curent menuItem. The handler must be specified as a function or string of script. Return false to disable the menuItem or true to enable it

      If you don't need to set this state dynamically, use `enabled` instead.

    - #### setCheckIfCondition

          public void setCheckIfCondition(MenuItemIfFunction checkIf)

      Contains the condition that will check or uncheck the curent menuItem. The handler must be specified as a function or string of script. Return false to uncheck the menuItem or true to check it

      If you don't need to set this state dynamically, use `checked` instead.

    - #### setDynamicTitleFunction

          public void setDynamicTitleFunction(MenuItemStringFunction handler)

      Contains the condition that will change the curent items' title when met. The handler must be specified as a function or string of script.

      If you don't need to set this state dynamically, use `title` instead.

    - #### setDynamicIconFunction

          public void setDynamicIconFunction(MenuItemStringFunction handler)

      Contains the condition that will change the curent items' icon when met. The handler must be specified as a function or string of script.

      If you don't need to set this state dynamically, use `icon` instead.