From 3d71041aa279bc7ea48e41795cfe00ac13623111 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sun, 26 Jun 2022 17:52:08 +0200 Subject: [PATCH] Update Checkbox.md --- docs/objects/Checkbox.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/objects/Checkbox.md b/docs/objects/Checkbox.md index 585d5ce..ae36ef2 100644 --- a/docs/objects/Checkbox.md +++ b/docs/objects/Checkbox.md @@ -1,13 +1,20 @@ -With checkbox, the user can set a bool to true or false +With checkbox objects the user can set a bool to true or false -Here are all possible functions available for checkbox: -Remember button also inherits from [Object](objects/Object.md) +Remember checkbox also inherits from [Object](objects/Object.md) +A checkbox does not have any custom methods. All required methods are provided by the base [object](objects/Object.md) class. -Create a onChange event: +# Example +This is how you would create a event which gets fired as soon as the value gets changed. ```lua local mainFrame = basalt.createFrame("myFirstFrame"):show() -local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):onChange(function(self) basalt.debug("The value got changed into "..self:getValue()) end):show() +local aCheckbox = mainFrame:addCheckbox("myFirstCheckbox"):show() + +local function checkboxChange(self) + local checked = self:getValue() + basalt.debug("The value got changed into ", checked) end) +end +aCheckbox:onChange(checkboxChange) ```