Difference between revisions of "Lua:Class:Menu"

From Cheat Engine
Jump to navigation Jump to search
(Major overhaul of the post.)
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
Menu '''class''': ('''Inheritance''': ''[[Lua:Class:Component|Component]]''->''[[Lua:Class:Object|Object]]'')
+
{{CodeBox|'''class''' Menu ''':''' Component}}
  
Class for menu objects used in [[Lua:Class:Form|Form]]s.
+
The Menu class represents a menu component.
  
== Properties ==
+
A Menu inherits from Component and Object. It provides access to the root MenuItem object through the Items property or the getItems() method.
; Items : MenuItem : ''Readonly''
 
: The base [[Lua:Class:MenuItem|MenuItem]] class of this Menu.
 
  
== Methods ==
+
===Inheritance===
; getItems() : MenuItem
+
{|width="85%" cellpadding="10%" cellspacing="0" border="0"
: Returns the main [[Lua:Class:MenuItem|MenuItem]] of this Menu.
+
!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}}
  
=== Related Functions ===
+
{{Forms}}
* [[Lua:createMainMenu|createMainMenu]]
 
* [[Lua:createMenuItem|createMenuItem]]
 
* [[Lua:createPopupMenu|createPopupMenu]]
 
 
 
=== Related Classes ===
 
* [[Lua:Class:Menu|Menu]]
 
* [[Lua:Class:MenuItem|MenuItem]]
 
* [[Lua:Class:PopupMenu|PopupMenu]]
 
* [[Lua:Class:Form|Form]]
 
* [[Lua:Class:Control|Control]]
 
* [[Lua:Class:Component|Component]]
 
* [[Lua:Class:WinControl|WinControl]]
 

Revision as of 00:27, 25 June 2026

<> Lua API Reference

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.

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()

Main Pages

Core Lua documentation entry points

Lua
Script Engine

Form Related Classes