Difference between revisions of "Lua:Class:Menu"
Jump to navigation
Jump to search
(Major overhaul of the post.) |
|||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | + | {{CodeBox|'''class''' Menu ''':''' Component}} | |
| − | + | The Menu class represents a menu component. | |
| − | + | A Menu inherits from Component and Object. It provides access to the root MenuItem object through the Items property or the getItems() method. | |
| − | |||
| − | |||
| − | == Methods == | + | ===Inheritance=== |
| − | ; getItems() | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" |
| − | + | !align="left"|Class | |
| + | !align="left"|Inherits From | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |Menu | ||
| + | |Component | ||
| + | |A menu component that provides access to its root MenuItem. | ||
| + | |- | ||
| + | |Component | ||
| + | |Object | ||
| + | |Base class for components. | ||
| + | |} | ||
| + | |||
| + | ===Properties=== | ||
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Property | ||
| + | !align="left"|Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |Items | ||
| + | |MenuItem | ||
| + | |The base MenuItem object of this menu. This property is read-only. | ||
| + | |} | ||
| + | |||
| + | ===Methods=== | ||
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Method | ||
| + | !align="left"|Return Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |getItems() | ||
| + | |MenuItem | ||
| + | |Returns the main MenuItem object of this menu. | ||
| + | |} | ||
| + | |||
| + | ===Examples=== | ||
| + | <pre> | ||
| + | local form = createForm() | ||
| + | local menu = createMainMenu(form) | ||
| + | |||
| + | form.Menu = menu | ||
| + | |||
| + | local root = menu.Items | ||
| + | |||
| + | local fileItem = createMenuItem(menu) | ||
| + | fileItem.Caption = "File" | ||
| + | root.add(fileItem) | ||
| + | |||
| + | form.show() | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | local form = createForm() | ||
| + | local menu = createMainMenu(form) | ||
| + | |||
| + | form.Menu = menu | ||
| + | |||
| + | local root = menu.getItems() | ||
| + | |||
| + | local item = createMenuItem(menu) | ||
| + | item.Caption = "Example" | ||
| + | |||
| + | root.add(item) | ||
| + | |||
| + | form.show() | ||
| + | </pre> | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | + | {{Forms}} | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Revision as of 00:27, 25 June 2026
The Menu class represents a menu component.
A Menu inherits from Component and Object. It provides access to the root MenuItem object through the Items property or the getItems() method.
Contents
Inheritance
| Class | Inherits From | Description |
|---|---|---|
| Menu | Component | A menu component that provides access to its root MenuItem. |
| Component | Object | Base class for components. |
Properties
| Property | Type | Description |
|---|---|---|
| Items | MenuItem | The base MenuItem object of this menu. This property is read-only. |
Methods
| Method | Return Type | Description |
|---|---|---|
| getItems() | MenuItem | Returns the main MenuItem object of this menu. |
Examples
local form = createForm() local menu = createMainMenu(form) form.Menu = menu local root = menu.Items local fileItem = createMenuItem(menu) fileItem.Caption = "File" root.add(fileItem) form.show()
local form = createForm() local menu = createMainMenu(form) form.Menu = menu local root = menu.getItems() local item = createMenuItem(menu) item.Caption = "Example" root.add(item) form.show()