Docs test
This commit is contained in:
@@ -13,6 +13,8 @@ Checkbox.defineProperty(Checkbox, "symbol", {default = "x", type = "string"})
|
||||
|
||||
Checkbox.listenTo(Checkbox, "mouse_click")
|
||||
|
||||
--- Creates a new Checkbox instance
|
||||
--- @return Checkbox self The created instance
|
||||
function Checkbox.new()
|
||||
local self = setmetatable({}, Checkbox):__init()
|
||||
self.set("width", 1)
|
||||
@@ -20,19 +22,29 @@ function Checkbox.new()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Initializes the Checkbox instance
|
||||
--- @param props table The properties to initialize the element with
|
||||
--- @param basalt table The basalt instance
|
||||
function Checkbox:init(props, basalt)
|
||||
VisualElement.init(self, props, basalt)
|
||||
self.set("type", "Checkbox")
|
||||
end
|
||||
|
||||
--- Handles mouse click events
|
||||
--- @param button number The button that was clicked
|
||||
--- @param x number The x position of the click
|
||||
--- @param y number The y position of the click
|
||||
--- @return boolean Whether the event was handled
|
||||
function Checkbox:mouse_click(button, x, y)
|
||||
if VisualElement.mouse_click(self, button, x, y) then
|
||||
self.set("checked", not self.get("checked"))
|
||||
self:fireEvent("change", self.get("checked"))
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
--- Renders the Checkbox
|
||||
function Checkbox:render()
|
||||
VisualElement.render(self)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user