From 5935cfeba45fd95a85723ef545dd8209cd086d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elm=C4=81rs=20=C4=80boli=C5=86=C5=A1?= Date: Thu, 1 Jul 2021 01:40:26 +0300 Subject: [PATCH] fix --- shell/checkbox.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/shell/checkbox.lua b/shell/checkbox.lua index 37b0a53..396bfe8 100644 --- a/shell/checkbox.lua +++ b/shell/checkbox.lua @@ -1,4 +1,4 @@ -local path = string.sub(..., 1, string.len(...) - string.len(".shell.button")) +local path = string.sub(..., 1, string.len(...) - string.len(".shell.checkbox")) local state = require(path.. ".hooks.state") local input = require(path.. ".core.input") @@ -21,22 +21,23 @@ local input = require(path.. ".core.input") return function(onClick, onRelease, onEnter, onExit, startOn, x, y, w, h) local checkbox = state { down = false, - toggled = not not startOn, + toggled = false, over = false, } + checkbox.toggled = startOn input('clicked', function(x, y, w, h) + checkbox.down = true + if onClick then onClick(x, y, w, h) end - - checkbox.down = true - return function(x, y, w, h) - if onRelease then - onRelease(x, y, w, h) - end checkbox.toggled = not checkbox.toggled checkbox.down = false + + if onRelease then + onRelease(checkbox.toggled, y, w, h) + end end end)