MenuItem.Constructor(Text as String, Tag as Variant)
From Xojo Documentation
Constructor
Creates a new MenuItem that uses the passed string as its Text property and optionally adds the passed Tag.
Examples
This example inserts a new item in the Edit menu with the text "Paste Special..." just below the Paste item.
Var editPasteSpecial As New MenuItem
editPasteSpecial.Text = "Paste Special..."
EditMenu.AddMenuAt(5, editPasteSpecial)
editPasteSpecial.Text = "Paste Special..."
EditMenu.AddMenuAt(5, editPasteSpecial)
Using this constructor, you can rewrite the code above more concisely:
This example illustrates how you can manipulate the menu bar at run time. By adding this example to the open even of a window it will add a new menu to menubar when the window opens.
Var m As MenuItem
Var mNew As MenuItem
m = Self.MenuBar
mNew = New MenuItem
mNew.Text = "MyMenuText"
mNew.Name = "MyMenuName"
Var submenu As New MenuItem("MySub")
submenu.AddMenu(New MenuItem("Submenu One"))
submenu.AddMenu(New MenuItem("Submenu Two"))
submenu.AddMenu(New MenuItem("Submenu three"))
mNew.AddMenu(submenu)
m.AddMenu(mNew)
Var mNew As MenuItem
m = Self.MenuBar
mNew = New MenuItem
mNew.Text = "MyMenuText"
mNew.Name = "MyMenuName"
Var submenu As New MenuItem("MySub")
submenu.AddMenu(New MenuItem("Submenu One"))
submenu.AddMenu(New MenuItem("Submenu Two"))
submenu.AddMenu(New MenuItem("Submenu three"))
mNew.AddMenu(submenu)
m.AddMenu(mNew)