MenuItem.Append

From Real Software Documentation

Jump to: navigation, search
Method
MenuItem.Append ( Item as MenuItem )

Appends the passed MenuItem to the menu. You can append a Separator by passing the class constant MenuItem.TextSeparator. Used to build a dynamic menu.

Examples

The following example creates a contextual menu in the ConstructContextualMenu event of any Window or RectControl. This event passes in the parameter base as MenuItem.

base.append(New MenuItem("Import"))
base.append(New MenuItem("Export"))
base.append(New MenuItem(MenuItem.TextSeparator))

base.append(New MenuItem("Cut"))
base.append(New MenuItem("Copy"))
base.append(New MenuItem("Paste"))
Return True //display the contextual menu


The following example creates a hierarchical menu that is added to the main menubar. It is in the Open event of the App or the window. It’s easiest to create menus and menuitems using the built-in Menu Editor and enable the MenuItems using the Autoenable property. Use code for cases such as dynamic menus and contextual menus.

dim m,mNew as MenuItem
m=self.menubar
mNew=New MenuItem

mNew.text="Fonts"
mNew.name="Fonts"

mNew.Append(new menuitem("TestOne"))
mNew.Append(new menuitem("Testtwo"))
mNew.Append(new menuitem("Testthree"))

mNew.Append( new MenuItem( "-" ) )

dim submenu as New Menuitem("MySub")

submenu.Append(new menuitem("submenu One"))
submenu.Append(new menuitem("submenu Two"))
submenu.Append(new menuitem("submenu three"))

m.Append mnew
mNew.Append submenu
Personal tools