# AddMenuItem

Objects
Menu
5.1 OC
int
string caption Text of the new menu entry
string command Command to be executed when the menu item is selected. This can be either a function name or a statement. If a function name is given then the function will be called in the object which was given as command_object to CreateMenu.
id symbol The ID is used as a picture for the menu item. The name of the definition can be used in caption using %s. Also the ID is passed as the first parameter to the call to command in case it is a function name.
int count Numeric value to be displayed next to the menu entry (such as counts and amounts).
any parameter Second parameter to the function specified in command (see remark).
string info_caption Description text of the new menu entry.
int extra Extra parameter for special behaviour of the menu entry.
Lower 7 bits (0-127): menu symbol.
0: normal
1: rank symbol. With symbol specified, the Rank.png component of that definition will be used. count indicates the rank
2: picture facet, shifted to the right by XPar1 times the facet width. This is used to include multiple menu symbols in a single definition.
3: XPar1 specifies an object to be drawn with the rank symbol. If the object has no info section (and thus no rank), there will be an empty entry in context menus.
4: XPar1 specifies an object to be drawn.
Bit 8 (128): XPar2 is used as object value and overrides the normal object value. Also see extra in CreateMenu
any XPar1 First additional parameter for extra.
any XPar2 Second additional parameter for extra.
Adds a menu entry.
Custom menu symbols should best have square aspect ratio.
If a function name is specified for command, the following parameters are passed: `symbol, parameter, bRight[, value]` with bRight indicating whether the menu entry was selected with [Special2] or the right mouse button. value is passed only if bit 8 is set in extra and specifies the displayed (overridden) object value of the menu entry.
func ControlUse() { // Create local menu with local commandos CreateMenu(GetID()); // Create menu items AddMenuItem("Say hello", "SayHello"); AddMenuItem("Do magic", "DoMagic"); AddMenuItem("Create an object: %s", "CreateItem", Rock); AddMenuItem("Create another object: %s", "CreateItem", Firestone); }

func SayHello() { Message("Hello",this); }

func DoMagic() { Sound("Magic*"); }

func CreateItem(id item) { CreateContents(item); }
Menu for a special item.
CreateMenu
SelectMenuItem
CloseMenu
jwk
2002-04