Class

# MobileMenuItem

<div class="rst-class">

forsearch

</div>

Menu

<div class="rst-class">

forsearch

</div>

MenuItem

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

## Description

An individual menu item in a mobile project.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                                        | Type                                                       | Read-Only | Shared |
|---------------------------------------------|------------------------------------------------------------|-----------|--------|
| `Destructive<mobilemenuitem.destructive>`   | `Boolean</api/data_types/boolean>`                         |           |        |
| `DisplayMode<mobilemenuitem.displaymode>`   | `MobileMenuItem.DisplayModes<mobilemenuitem.displaymodes>` |           |        |
| `Enabled<mobilemenuitem.enabled>`           | `Boolean</api/data_types/boolean>`                         |           |        |
| `HasCheckMark<mobilemenuitem.hascheckmark>` | `Boolean</api/data_types/boolean>`                         |           |        |
| `Icon<mobilemenuitem.icon>`                 | `Picture</api/graphics/picture>`                           |           |        |
| `LastRowIndex<mobilemenuitem.lastrowindex>` | `Integer</api/data_types/integer>`                         | ✓         |        |
| `Shortcut<mobilemenuitem.shortcut>`         | `String</api/data_types/string>`                           |           |        |
| `Tag<mobilemenuitem.tag>`                   | `Variant</api/data_types/variant>`                         |           |        |
| `Text<mobilemenuitem.text>`                 | `String</api/data_types/string>`                           |           |        |
| `Visible<mobilemenuitem.visible>`           | `Boolean</api/data_types/boolean>`                         |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                        | Parameters                                                                                                     | Returns                                       | Shared |
|---------------------------------------------|----------------------------------------------------------------------------------------------------------------|-----------------------------------------------|--------|
| `AddMenu<mobilemenuitem.addmenu>`           | menu As <span class="title-ref">MobileMenuItem</span>                                                          |                                               |        |
| `AddMenuAt<mobilemenuitem.addmenuat>`       | index As `Integer</api/data_types/integer>`, menu As <span class="title-ref">MobileMenuItem</span>             |                                               |        |
| `Child<mobilemenuitem.child>`               | value As `String</api/data_types/string>`                                                                      | <span class="title-ref">MobileMenuItem</span> |        |
| `Clone<mobilemenuitem.clone>`               |                                                                                                                | <span class="title-ref">MobileMenuItem</span> |        |
| `Constructor<mobilemenuitem.constructor>`   | copy As <span class="title-ref">MobileMenuItem</span>                                                          |                                               |        |
|                                             | text As `String</api/data_types/string>`, tag As `Variant</api/data_types/variant>` = `Nil</api/language/nil>` |                                               |        |
| `Count<mobilemenuitem.count>`               |                                                                                                                | `Integer</api/data_types/integer>`            |        |
| `MenuAt<mobilemenuitem.menuat>`             | index As `Integer</api/data_types/integer>`                                                                    | <span class="title-ref">MobileMenuItem</span> |        |
| `RemoveMenuAt<mobilemenuitem.removemenuat>` | index As `Integer</api/data_types/integer>`                                                                    |                                               |        |

## Constants

> The following class constant is used to add a separator item to a menu. Use this constant to add a separator with the AddMenu or AddMenuAt methods:
>
> | Class Constant | Description                                    |
> |----------------|------------------------------------------------|
> | TextSeparator  | A menu separator (supported for Android only). |

## Enumerations

<div id="mobilemenuitem.displaymodes">

<div class="rst-class">

forsearch

</div>

</div>

MobileMenuItem.DisplayModes

### DisplayModes

> Appearance modes of a <span class="title-ref">MobileMenuItem</span>.
>
> | Name    |
> |---------|
> | Regular |
> | Palette |

## Property descriptions

<div id="mobilemenuitem.destructive">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Destructive

**Destructive** As `Boolean</api/data_types/boolean>`

> The <span class="title-ref">MobileMenuItem</span> will be displayed as a destructive action.

<div id="mobilemenuitem.displaymode">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.DisplayMode

**DisplayMode** As `MobileMenuItem.DisplayModes<mobilemenuitem.displaymodes>`

> Used to set or get the appearance if the <span class="title-ref">MobileMenuItem</span>.
>
> `DisplayModes<mobilemenuitem.displaymodes>` is an Enum with the following values:
>
> - Regular (Default)
> - Palette (Displays the options in a palette with horizontal scrolling for the available options, if these doesn't fit in the available area.)
>
> <div class="important">
>
> <div class="title">
>
> Important
>
> </div>
>
> This property is not currently supported for Android.
>
> </div>

<div id="mobilemenuitem.enabled">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Enabled

**Enabled** As `Boolean</api/data_types/boolean>`

> Indicates whether or not the menu item is enabled.

<div id="mobilemenuitem.hascheckmark">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.HasCheckMark

**HasCheckMark** As `Boolean</api/data_types/boolean>`

> Indicates whether or not the menu item is checked.

<div id="mobilemenuitem.icon">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Icon

**Icon** As `Picture</api/graphics/picture>`

> A picture that is assigned to the <span class="title-ref">MobileMenuItem</span>.

<div id="mobilemenuitem.lastrowindex">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.LastRowIndex

**LastRowIndex** As `Integer</api/data_types/integer>`

> The index of the last child menu item owned by this menu.
>
> This property is read-only.

<div id="mobilemenuitem.shortcut">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Shortcut

**Shortcut** As `String</api/data_types/string>`

> The virtual keyboard shortcut for the <span class="title-ref">MobileMenuItem</span>.
>
> Use this property to set the shortcut in code.

<div id="mobilemenuitem.tag">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Tag

**Tag** As `Variant</api/data_types/variant>`

> A "hidden" value associated with the menu item.
>
> The tag is accessible via code when the user chooses the menu item but, unlike the Text property, is not displayed in the menu. It works like the RowTagAt method of a `MobilePopupMenu</api/user_interface/mobile/mobilepopupmenu>` control.

<div id="mobilemenuitem.text">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Text

**Text** As `String</api/data_types/string>`

> The value (text) of the menu item.

<div id="mobilemenuitem.visible">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Visible

**Visible** As `Boolean</api/data_types/boolean>`

> Indicates whether or not the menu item is visible. The default is `True</api/language/true>`. If `False</api/language/false>`, the menu item does not appear and no blank space is for it is in the menu.

## Method descriptions

<div id="mobilemenuitem.addmenu">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.AddMenu

**AddMenu**(menu As <span class="title-ref">MobileMenuItem</span>)

> Adds the passed <span class="title-ref">MobileMenuItem</span> to the menu. Used to build a dynamic menu.
>
> On Android, you can add a Separator by passing the class constant `MobileMenuItem.TextSeparator`.
>
> The following code creates a hierarchical menu that is added to a `MobileButton.Menu<mobilebutton.menu>`. It is in the Opening event of the button.
>
> ``` xojo
> Var mNew As New MobileMenuItem("View")
>
> mNew.AddMenu(New MobileMenuItem("As Icons"))
> mNew.AddMenu(New MobileMenuItem("As List"))
> mNew.AddMenu(New MobileMenuItem("As Columns"))
>
> #If TargetAndroid
>   mNew.AddMenu(MobileMenuItem.TextSeparator)
> #EndIf
>
> Var submenu As New MobileMenuItem("Sort By")
> submenu.AddMenu(New MobileMenuItem("Name"))
> submenu.AddMenu(New MobileMenuItem("Kind"))
> submenu.AddMenu(New MobileMenuItem("Size"))
>
> mNew.AddMenu(submenu) 
>
> Me.Menu = mNew
> ```

<div id="mobilemenuitem.addmenuat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.AddMenuAt

**AddMenuAt**(index As `Integer</api/data_types/integer>`, menu As <span class="title-ref">MobileMenuItem</span>)

> Adds *menu* as a <span class="title-ref">MobileMenuItem</span> at the position indicated by *index*. Index is zero-based.
>
> An Android, you can add a separator by passing the class constant `MobileMenuItem.TextSeparator`.
>
> The following example adds a new item to an existing <span class="title-ref">MobileMenuItem</span> instance representing the Edit menu. The new item, titled “Paste Special…”, is inserted directly below the Paste item.
>
> ``` xojo
> Var editPasteSpecial As New MobileMenuItem
> editPasteSpecial.Text = "Paste Special..."
>
> EditMenu.AddMenuAt(5, editPasteSpecial)
> ```

<div id="mobilemenuitem.child">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Child

**Child**(value As `String</api/data_types/string>`) As <span class="title-ref">MobileMenuItem</span>

> Looks up menu items by *value* and returns a <span class="title-ref">MobileMenuItem</span>. Returns `Nil</api/language/nil>` if a child is not found.
>
> The following example gets the text of the Edit \> Cut menuitem.
>
> ``` xojo
> Var c As MobileMenuItem = EditMenu.Child("EditCut")
> MessageBox(c.Text)
> ```

<div id="mobilemenuitem.clone">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Clone

**Clone** As <span class="title-ref">MobileMenuItem</span>

> Makes a copy of the <span class="title-ref">MobileMenuItem</span> and its `children<mobilemenuitem.child>` if any.
>
> Whenever you need to use the same <span class="title-ref">MobileMenuItem</span> in different places, use the Clone method to create a new copy of the <span class="title-ref">MobileMenuItem</span> and its children, if any.
>
> ``` xojo
> Var mi As New MobileMenuItem("My menu item")
> Var myClone As MobileMenuItem
>
> myClone = mi.Clone ' Creates an independent copy of "mi"
> ```

<div id="mobilemenuitem.constructor">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Constructor

**Constructor**(copy As <span class="title-ref">MobileMenuItem</span>)

> <div class="note">
>
> <div class="title">
>
> Note
>
> </div>
>
> `Constructors</api/language/constructor>` are special methods called when you create an Object With the `New</api/language/New>` keyword And pass In the parameters above.
>
> </div>
>
> Creates a new <span class="title-ref">MobileMenuItem</span> that is a duplicate of the provided <span class="title-ref">MobileMenuItem</span> *copy*.

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

**Constructor**(text As `String</api/data_types/string>`, tag As `Variant</api/data_types/variant>` = `Nil</api/language/nil>`)

> Creates a new <span class="title-ref">MobileMenuItem</span> that uses the passed string as its *text* property and optionally adds the passed *tag*. You can add a Separator by passing the class constant `MobileMenuItem.TextSeparator`.

<div id="mobilemenuitem.count">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.Count

**Count** As `Integer</api/data_types/integer>`

> Returns as an `Integer</api/data_types/integer>` the number of children a menu owns.
>
> For a menu item, it returns the number of submenu items, if any. If there are no submenu items, it returns zero.

<div id="mobilemenuitem.menuat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.MenuAt

**MenuAt**(index As `Integer</api/data_types/integer>`) As <span class="title-ref">MobileMenuItem</span>

> Item returns as a <span class="title-ref">MobileMenuItem</span> the item indicated by the *index* passed.
>
> If the passed index is out of range, an `OutOfBoundsException</api/exceptions/outofboundsexception>` is raised.
>
> The following example gets the <span class="title-ref">MobileMenuItem</span> corresponding to the Cut item on the Edit menu by position:
>
> ``` xojo
> Var c As MobileMenuItem = EditMenu.MenuAt(2)
> MessageBox(c.Text)
> ```

<div id="mobilemenuitem.removemenuat">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

MobileMenuItem.RemoveMenuAt

**RemoveMenuAt**(index As `Integer</api/data_types/integer>`)

> Removes the <span class="title-ref">MobileMenuItem</span> specified by its position *index*.
>
> This example removes the menu item at the third position from the Edit menu.
>
> ``` xojo
> EditMenu.RemoveMenuAt(3)
> ```

## Compatibility

|                       |        |
|-----------------------|--------|
| **Project Types**     | Mobile |
| **Operating Systems** | All    |

<div class="seealso">

`Object</api/data_types/additional_types/object>` parent class; `MobileButton</api/user_interface/mobile/mobilebutton>`, `MobileToolbarButton</api/user_interface/mobile/mobiletoolbarbutton>` and `MobileScreen</api/user_interface/mobile/mobilescreen>` classes

</div>
