Menu

Group
player
Methods
9
Fields
None

Getting one

client:getMenu()
client:createMenuEntry(…):getSubMenu()
client:createMenuEntry(…):createSubMenu()

Methods

MethodReturnsDescription
createMenuEntry(number)MenuEntryCreate a new entry at idx (a negative index counts from the end: -1 puts it on top) and return it: option and target empty, type `MenuAct…
getMenuEntries(){MenuEntry}The menu's entries, bottom first: a 1-based array whose last element is the top entry.
setMenuEntries({MenuEntry})()Make the menu exactly entries, in that order (bottom first): what is left out is removed, what is listed again after a removal comes back…
removeMenuEntry(MenuEntry)()Remove entry. Raises for an entry of another menu.
getMenuX()numberThe open menu's left edge, in canvas pixels; the last open menu's after it closed (0 before one opened).
getMenuY()numberThe open menu's top edge, in canvas pixels.
getMenuWidth()numberThe open menu's width.
getMenuHeight()numberThe open menu's height.
equals(any)booleanWhether other equals this Menu, as == answers it (false for a value of another class).

Returned by

MethodReturnsDescription
Client.getMenuMenuThe root right-click menu (one object for the client's life).
MenuEntry.createSubMenuMenuA new, empty submenu for the entry, replacing any. Raises where the client's menu cannot hold one.
MenuEntry.getSubMenuMenu?The entry's submenu, or nil when it has none.

Method details

createMenuEntry

createMenuEntry: (Menu, number) -> MenuEntry

Create a new entry at idx (a negative index counts from the end: -1 puts it on top) and return it: option and target empty, type MenuAction.CLIENT, identifier and params 0, item id -1. It is not announced by MenuEntryAdded. Raises for an index past the end or a full menu. Made before the client's last sort (in MenuEntryAdded), it then moves as that sort moves it: a type over 1000 (CLIENT, the default) sinks below every entry under 1000; made at PostMenuSort or MenuOpened, idx is where it stays.

getMenuEntries

getMenuEntries: (Menu) -> {MenuEntry}

The menu's entries, bottom first: a 1-based array whose last element is the top entry.

setMenuEntries

setMenuEntries: (Menu, {MenuEntry}) -> ()

Make the menu exactly entries, in that order (bottom first): what is left out is removed, what is listed again after a removal comes back. Most useful in MenuOpened and PostMenuSort, after the client's last sort (before it, that sort still sinks every entry over 1000 below the others). Raises for an entry of another menu or one listed twice.

getMenuX

getMenuX: (Menu) -> number

The open menu's left edge, in canvas pixels; the last open menu's after it closed (0 before one opened).

getMenuY

getMenuY: (Menu) -> number

The open menu's top edge, in canvas pixels.

equals

equals: (Menu, any) -> boolean

Whether other equals this Menu, as == answers it (false for a value of another class).