Fix ChangeableObject docs #63
@@ -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
|
||||
|
||||
@@ -30,7 +30,6 @@ Events are actions or occurrences that happen during the execution of your progr
|
||||
|[onKey](objects/Object/onKey.md)|Fires when the object is focused and a keyboard key is pressed
|
||||
|[onChar](objects/Object/onChar.md)|Fires when the object is focused and a character key is pressed
|
||||
|[onKeyUp](objects/Object/onKeyUp.md)|Fires when the object is focused and a keyboard key is released
|
||||
|[onChange](objects/Object/onChange.md)|Fires when the object value has changed
|
||||
|[onGetFocus](objects/Object/onGetFocus.md)|Fires when the object gains focus
|
||||
|[onLoseFocus](objects/Object/onLoseFocus.md)|Fires when the object loses focus
|
||||
|[onEvent](objects/Object/onEvent.md)|Fires for any other event
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# Object - Event
|
||||
|
||||
## onChange
|
||||
|
||||
`onChange(self)`
|
||||
|
||||
This is a custom event which gets triggered as soon as the function :setValue() is called. This function is also called by basalt, for example if you change the input, textfield or checkbox (or all the different types of lists) objects.
|
||||
|
||||
Here is a example on how to add a onChange event to your input, and also another example for your checkbox:
|
||||
|
||||
```lua
|
||||
local basalt = require("basalt")
|
||||
|
||||
local main = basalt.createFrame()
|
||||
local aInput = main:addInput():setPosition(3,3)
|
||||
local aCheckbox = main:addCheckbox():setPosition(3,5)
|
||||
|
||||
local function checkInput(input)
|
||||
if(string.lower(input:getValue())=="hello")then
|
||||
basalt.debug("Hello back!")
|
||||
end
|
||||
end
|
||||
|
||||
local function checkCheckbox(checkbox)
|
||||
if(checkbox:getValue()==true)then -- or if(checkbox:getValue())then
|
||||
basalt.debug("Checkbox is active, let's do something!")
|
||||
end
|
||||
end
|
||||
|
||||
aInput:onChange(checkInput)
|
||||
aCheckbox:onChange(checkCheckbox)
|
||||
```
|
||||
Reference in New Issue
Block a user