Difference between revisions of "Lua:Class:Button"
Jump to navigation
Jump to search
AntumDeluge (talk | contribs) (Update inheritence link) |
|||
| Line 1: | Line 1: | ||
[[Category:Lua]] | [[Category:Lua]] | ||
| − | + | {{NeedWork}} | |
| + | {{CodeBox|'''class''' Button ''':''' ButtonControl}} | ||
| − | + | The Button class represents a clickable button control. | |
| − | + | A Button inherits from ButtonControl, WinControl, Control, Component, and Object. It can be created with createButton and must belong to an owner inherited from WinControl. | |
| − | + | ===Inheritance=== | |
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Class | ||
| + | !align="left"|Inherits From | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |Button | ||
| + | |ButtonControl | ||
| + | |A clickable button control. | ||
| + | |- | ||
| + | |ButtonControl | ||
| + | |WinControl | ||
| + | |Base class for button-like controls. | ||
| + | |- | ||
| + | |WinControl | ||
| + | |Control | ||
| + | |Base class for windowed controls. | ||
| + | |- | ||
| + | |Control | ||
| + | |Component | ||
| + | |Base class for visual controls. | ||
| + | |- | ||
| + | |Component | ||
| + | |Object | ||
| + | |Base class for components. | ||
| + | |} | ||
| − | == Creation == | + | ===Creation=== |
| + | {{CodeBox|'''function''' createButton(''owner'') ''':''' Button}} | ||
| − | + | Creates a Button object that belongs to the given owner. | |
| − | |||
| − | + | The owner can be any object inherited from WinControl. | |
| − | ; | + | ===Function Parameters=== |
| − | + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | |
| + | !align="left"|Parameter | ||
| + | !align="left"|Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |owner | ||
| + | |WinControl | ||
| + | |The owner of the button. This can be any object inherited from WinControl. | ||
| + | |} | ||
| − | == | + | ===Properties=== |
| + | {|width="85%" cellpadding="10%" cellspacing="0" border="0" | ||
| + | !align="left"|Property | ||
| + | !align="left"|Type | ||
| + | !style="width: 80%;background-color:white;" align="left"|Description | ||
| + | |- | ||
| + | |ModalResult | ||
| + | |ModalResult | ||
| + | |The result this button will give the modal form when clicked. | ||
| + | |} | ||
| − | ; getModalResult( | + | ===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 | ||
| + | |- | ||
| + | |getModalResult(button) | ||
| + | |ModalResult | ||
| + | |Returns the ModalResult value of the specified button. | ||
| + | |- | ||
| + | |setModalResult(button, mr) | ||
| + | |void | ||
| + | |Sets the ModalResult value of the specified button. | ||
| + | |} | ||
| − | + | ===Examples=== | |
| − | : | + | <pre> |
| + | local form = createForm() | ||
| + | form.Caption = "Button Example" | ||
| + | |||
| + | local button = createButton(form) | ||
| + | button.Parent = form | ||
| + | button.Caption = "Close" | ||
| + | button.Left = 20 | ||
| + | button.Top = 20 | ||
| + | button.Width = 100 | ||
| + | |||
| + | button.ModalResult = mrOK | ||
| + | |||
| + | form.showModal() | ||
| + | form.destroy() | ||
| + | </pre> | ||
| + | |||
| + | <pre> | ||
| + | local form = createForm() | ||
| + | form.Caption = "Button Example" | ||
| + | |||
| + | local button = createButton(form) | ||
| + | button.Parent = form | ||
| + | button.Caption = "OK" | ||
| + | |||
| + | setModalResult(button, mrOK) | ||
| + | |||
| + | print("ModalResult: " .. tostring(getModalResult(button))) | ||
| + | |||
| + | form.destroy() | ||
| + | </pre> | ||
{{LuaSeeAlso}} | {{LuaSeeAlso}} | ||
| − | |||
| − | |||
| − | |||
Revision as of 09:43, 21 June 2026
The Button class represents a clickable button control.
A Button inherits from ButtonControl, WinControl, Control, Component, and Object. It can be created with createButton and must belong to an owner inherited from WinControl.
Inheritance
| Class | Inherits From | Description |
|---|---|---|
| Button | ButtonControl | A clickable button control. |
| ButtonControl | WinControl | Base class for button-like controls. |
| WinControl | Control | Base class for windowed controls. |
| Control | Component | Base class for visual controls. |
| Component | Object | Base class for components. |
Creation
Creates a Button object that belongs to the given owner.
The owner can be any object inherited from WinControl.
Function Parameters
| Parameter | Type | Description |
|---|---|---|
| owner | WinControl | The owner of the button. This can be any object inherited from WinControl. |
Properties
| Property | Type | Description |
|---|---|---|
| ModalResult | ModalResult | The result this button will give the modal form when clicked. |
Methods
| Method | Return Type | Description |
|---|---|---|
| getModalResult(button) | ModalResult | Returns the ModalResult value of the specified button. |
| setModalResult(button, mr) | void | Sets the ModalResult value of the specified button. |
Examples
local form = createForm() form.Caption = "Button Example" local button = createButton(form) button.Parent = form button.Caption = "Close" button.Left = 20 button.Top = 20 button.Width = 100 button.ModalResult = mrOK form.showModal() form.destroy()
local form = createForm()
form.Caption = "Button Example"
local button = createButton(form)
button.Parent = form
button.Caption = "OK"
setModalResult(button, mrOK)
print("ModalResult: " .. tostring(getModalResult(button)))
form.destroy()