Fix changeable object docs

This commit is contained in:
Sabine Lim
2023-05-08 07:15:38 +10:00
parent e2bead28cb
commit 43ebd3fc3c
3 changed files with 7 additions and 64 deletions

View File

@@ -1,38 +1,14 @@
The ChangeableObject class is a subclass of VisualObject and Object that provides additional methods for handling changes to objects.
In addition to the Object and VisualObject methods, changeableObjects also have the following methods:
In addition to the Object and VisualObject methods, ChangeableObjects also have the following methods:
| | |
|---|---|
|[setValue](objects/Button/setText.md)|Changes the button text
|[getValue](objects/Button/setHorizontalAlign.md)|Changes the horizontal text position
|[onChange](objects/Button/setVerticalAlign.md)|Changes the vertical text position
|[setValue](objects/ChangeableObject/setValue.md)|Sets the value of your object
|[getValue](objects/ChangeableObject/getValue.md)|Gets the value of your object
# Example
### Events
Here's an example of how to create a fully functional button using the Button object:
```lua
local main = basalt.createFrame()
local aButton = main:addButton():setText("Click")
aButton:onClick(function(self,event,button,x,y)
if(event=="mouse_click")and(button==1)then
basalt.debug("Left mousebutton got clicked!")
end
end)
```
Alternatively, you can create a button using an XML layout:
```xml
<button onClick="buttonClick" text="Click">
<onClick>
if(event=="mouse_click")and(button==1)then
basalt.debug("Left mousebutton got clicked!")
end
</onClick>
</button>
```
In these examples, a button is created with the text "Click". When the left mouse button is clicked on the button, the message "Left mouse button got clicked!" is printed.
| | |
|---|---|
|[onChange](objects/ChangeableObject/onChange.md)|Fires when the object value has changed