Class

MobileMenuItem

Menu

MenuItem


Description

An individual menu item in a mobile project.

Properties

Name

Type

Read-Only

Shared

Destructive

Boolean

DisplayMode

MobileMenuItem.DisplayModes

Enabled

Boolean

HasCheckMark

Boolean

Icon

Picture

LastRowIndex

Integer

Shortcut

String

Tag

Variant

Text

String

Visible

Boolean

Methods

Name

Parameters

Returns

Shared

AddMenu

menu As MobileMenuItem

AddMenuAt

index As Integer, menu As MobileMenuItem

Child

value As String

MobileMenuItem

Clone

MobileMenuItem

Constructor

copy As MobileMenuItem

text As String, tag As Variant = Nil

Count

Integer

MenuAt

index As Integer

MobileMenuItem

RemoveMenuAt

index As 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

MobileMenuItem.DisplayModes

DisplayModes

Appearance modes of a MobileMenuItem.

Name

Regular

Palette

Property descriptions


MobileMenuItem.Destructive

Destructive As Boolean

The MobileMenuItem will be displayed as a destructive action.


MobileMenuItem.DisplayMode

DisplayMode As MobileMenuItem.DisplayModes

Used to set or get the appearance if the 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.)

Important

This property is not currently supported for Android.


MobileMenuItem.Enabled

Enabled As Boolean

Indicates whether or not the menu item is enabled.


MobileMenuItem.HasCheckMark

HasCheckMark As Boolean

Indicates whether or not the menu item is checked.


MobileMenuItem.Icon

Icon As Picture

A picture that is assigned to the MobileMenuItem.


MobileMenuItem.LastRowIndex

LastRowIndex As Integer

The index of the last child menu item owned by this menu.

This property is read-only.


MobileMenuItem.Shortcut

Shortcut As String

The virtual keyboard shortcut for the MobileMenuItem.

Use this property to set the shortcut in code.


MobileMenuItem.Tag

Tag As 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 control.


MobileMenuItem.Text

Text As String

The value (text) of the menu item.


MobileMenuItem.Visible

Visible As Boolean

Indicates whether or not the menu item is visible. The default is True. If False, the menu item does not appear and no blank space is for it is in the menu.

Method descriptions


MobileMenuItem.AddMenu

AddMenu(menu As MobileMenuItem)

Adds the passed MobileMenuItem 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. It is in the Opening event of the button.

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

MobileMenuItem.AddMenuAt

AddMenuAt(index As Integer, menu As MobileMenuItem)

Adds menu as a MobileMenuItem 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 MobileMenuItem instance representing the Edit menu. The new item, titled “Paste Special…”, is inserted directly below the Paste item.

Var editPasteSpecial As New MobileMenuItem
editPasteSpecial.Text = "Paste Special..."

EditMenu.AddMenuAt(5, editPasteSpecial)

MobileMenuItem.Child

Child(value As String) As MobileMenuItem

Looks up menu items by value and returns a MobileMenuItem. Returns Nil if a child is not found.

The following example gets the text of the Edit > Cut menuitem.

Var c As MobileMenuItem = EditMenu.Child("EditCut")
MessageBox(c.Text)

MobileMenuItem.Clone

Clone As MobileMenuItem

Makes a copy of the MobileMenuItem and its children if any.

Whenever you need to use the same MobileMenuItem in different places, use the Clone method to create a new copy of the MobileMenuItem and its children, if any.

Var mi As New MobileMenuItem("My menu item")
Var myClone As MobileMenuItem

myClone = mi.Clone ' Creates an independent copy of "mi"

MobileMenuItem.Constructor

Constructor(copy As MobileMenuItem)

Note

Constructors are special methods called when you create an Object With the New keyword And pass In the parameters above.

Creates a new MobileMenuItem that is a duplicate of the provided MobileMenuItem copy.


Constructor(text As String, tag As Variant = Nil)

Creates a new MobileMenuItem 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.


MobileMenuItem.Count

Count As Integer

Returns as an 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.


MobileMenuItem.MenuAt

MenuAt(index As Integer) As MobileMenuItem

Item returns as a MobileMenuItem the item indicated by the index passed.

If the passed index is out of range, an OutOfBoundsException is raised.

The following example gets the MobileMenuItem corresponding to the Cut item on the Edit menu by position:

Var c As MobileMenuItem = EditMenu.MenuAt(2)
MessageBox(c.Text)

MobileMenuItem.RemoveMenuAt

RemoveMenuAt(index As Integer)

Removes the MobileMenuItem specified by its position index.

This example removes the menu item at the third position from the Edit menu.

EditMenu.RemoveMenuAt(3)

Compatibility

Project Types

Mobile

Operating Systems

All

See also

Object parent class; MobileButton, MobileToolbarButton and MobileScreen classes