From 43ebd3fc3c1e94783ec1476f2e04b65a2597a8e2 Mon Sep 17 00:00:00 2001 From: Sabine Lim Date: Mon, 8 May 2023 07:15:38 +1000 Subject: [PATCH] Fix changeable object docs --- docs/objects/ChangeableObject.md | 38 ++++++-------------------------- docs/objects/Object.md | 1 - docs/objects/Object/onChange.md | 32 --------------------------- 3 files changed, 7 insertions(+), 64 deletions(-) delete mode 100644 docs/objects/Object/onChange.md diff --git a/docs/objects/ChangeableObject.md b/docs/objects/ChangeableObject.md index 1080723..2305de1 100644 --- a/docs/objects/ChangeableObject.md +++ b/docs/objects/ChangeableObject.md @@ -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 - -``` - -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 diff --git a/docs/objects/Object.md b/docs/objects/Object.md index 3ef9373..10d1c64 100644 --- a/docs/objects/Object.md +++ b/docs/objects/Object.md @@ -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 diff --git a/docs/objects/Object/onChange.md b/docs/objects/Object/onChange.md deleted file mode 100644 index 0bfa518..0000000 --- a/docs/objects/Object/onChange.md +++ /dev/null @@ -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) -```