Show / Hide Table of Contents

Method popupMenu.Add(+ 2 overloads)


Overload

Adds menu item with explicitly specified id.

public PMItem Add(int id, string text, MTImage image = default, bool disable = false, int l_ = 0, string f_ = null)
Parameters
id  (int)

Item id that popupMenu.Show will return if clicked this item.

text  (string)

Item text. Can include hotkey, tooltip and underlined character, like "Te&xt\t Hotkey\0 Tooltip"; more info: popupMenu.

image  (MTImage)

Item image. Read here: MTBase.

disable  (bool)

Disabled state.

l_  (int)

Caller info parameter

f_  (string)

Caller info parameter

Returns
PMItem

Overload(next)

Adds menu item with auto-generated id.

public PMItem Add(string text, MTImage image = default, bool disable = false, int l_ = 0, string f_ = null)
Parameters
text  (string)

Item text. Can include hotkey, tooltip and underlined character, like "Te&xt\t Hotkey\0 Tooltip"; more info: popupMenu.

image  (MTImage)

Item image. Read here: MTBase.

disable  (bool)

Disabled state.

l_  (int)

Caller info parameter

f_  (string)

Caller info parameter

Returns
PMItem

Remarks

Assigns id = the last specified or auto-generated id + 1. If not using explicitly specified ids, auto-generated ids are 1, 2, 3... Submenu-items, separators and items with action don't auto-generate ids.


Overload(top)

Adds menu item with action (callback function) that is executed on click.

public PMItem Add(string text, Action<PMItem> click, MTImage image = default, bool disable = false, int l_ = 0, string f_ = null)
Parameters
text  (string)

Item text. Can include hotkey, tooltip and underlined character, like "Te&xt\t Hotkey\0 Tooltip"; more info: popupMenu.

click  (Action<PMItem>)

Action executed on click.

image  (MTImage)

Item image. Read here: MTBase.

disable  (bool)

Disabled state.

l_  (int)

Caller info parameter

f_  (string)

Caller info parameter

Returns
PMItem

Remarks

This function is the same as the indexer. The difference is, Add returns PMItem object of the added item. When using the indexer, to access the item use popupMenu.Last. These codes are the same: var v=m.Add("text", o=>{});" and m["text"]=o=>{}; var v=m.Last;.