Fixed Checkbox element ignoring mouse events
This commit is contained in:
@@ -30,12 +30,15 @@ end})
|
|||||||
Checkbox.defineProperty(Checkbox, "autoSize", {default = true, type = "boolean"})
|
Checkbox.defineProperty(Checkbox, "autoSize", {default = true, type = "boolean"})
|
||||||
|
|
||||||
Checkbox.defineEvent(Checkbox, "mouse_click")
|
Checkbox.defineEvent(Checkbox, "mouse_click")
|
||||||
|
Checkbox.defineEvent(Checkbox, "mouse_up")
|
||||||
|
|
||||||
--- @shortDescription Creates a new Checkbox instance
|
--- @shortDescription Creates a new Checkbox instance
|
||||||
--- @return Checkbox self The created instance
|
--- @return Checkbox self The created instance
|
||||||
--- @protected
|
--- @protected
|
||||||
function Checkbox.new()
|
function Checkbox.new()
|
||||||
local self = setmetatable({}, Checkbox):__init()
|
local self = setmetatable({}, Checkbox):__init()
|
||||||
|
self.class = Checkbox
|
||||||
|
self.set("backgroundEnabled", false)
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -45,7 +48,6 @@ end
|
|||||||
--- @protected
|
--- @protected
|
||||||
function Checkbox:init(props, basalt)
|
function Checkbox:init(props, basalt)
|
||||||
VisualElement.init(self, props, basalt)
|
VisualElement.init(self, props, basalt)
|
||||||
self.class = Checkbox
|
|
||||||
self.set("type", "Checkbox")
|
self.set("type", "Checkbox")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -58,7 +60,6 @@ end
|
|||||||
function Checkbox:mouse_click(button, x, y)
|
function Checkbox:mouse_click(button, x, y)
|
||||||
if VisualElement.mouse_click(self, button, x, y) then
|
if VisualElement.mouse_click(self, button, x, y) then
|
||||||
self.set("checked", not self.get("checked"))
|
self.set("checked", not self.get("checked"))
|
||||||
self:fireEvent("change", self.get("checked"))
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in New Issue
Block a user