From 03b1380694562616a94d835163af8b3b8d44898f Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Mon, 1 Sep 2025 04:03:07 -0400 Subject: [PATCH 1/3] add defaultState parameter --- MasterFramework Dev/Framework/Controls/CheckBox.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/MasterFramework Dev/Framework/Controls/CheckBox.lua b/MasterFramework Dev/Framework/Controls/CheckBox.lua index 94a3070..f5ba744 100644 --- a/MasterFramework Dev/Framework/Controls/CheckBox.lua +++ b/MasterFramework Dev/Framework/Controls/CheckBox.lua @@ -1,15 +1,15 @@ -function framework:CheckBox(scale, action) +function framework:CheckBox(scale, defaultState, action) local checkbox local dimension = framework:AutoScalingDimension(scale) local radius = framework:AutoScalingDimension(scale / 2) - - local checked = false + + local checked = defaultState local highlightColor = framework.color.hoverColor local unhighlightedColor = framework.stroke.defaultBorder - local rect = framework:Background(framework:Rect(dimension, dimension), { unhihlightedColor }, radius) - + local rect = framework:Background(framework:Rect(dimension, dimension), { unhighlightedColor }, radius) + checkbox = framework:MouseOverChangeResponder( framework:MousePressResponder( rect, @@ -40,5 +40,6 @@ function framework:CheckBox(scale, action) end checkbox:SetChecked(checked) + action(checkbox, checked) return checkbox end \ No newline at end of file From 5f1b37273b609c3ccec52d2cf458f6678d0673a0 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Tue, 2 Sep 2025 20:02:45 -0400 Subject: [PATCH 2/3] move action to setChecked --- MasterFramework Dev/Framework/Controls/CheckBox.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/MasterFramework Dev/Framework/Controls/CheckBox.lua b/MasterFramework Dev/Framework/Controls/CheckBox.lua index f5ba744..b62d760 100644 --- a/MasterFramework Dev/Framework/Controls/CheckBox.lua +++ b/MasterFramework Dev/Framework/Controls/CheckBox.lua @@ -2,8 +2,7 @@ function framework:CheckBox(scale, defaultState, action) local checkbox local dimension = framework:AutoScalingDimension(scale) local radius = framework:AutoScalingDimension(scale / 2) - - local checked = defaultState + local checked local highlightColor = framework.color.hoverColor local unhighlightedColor = framework.stroke.defaultBorder @@ -24,7 +23,6 @@ function framework:CheckBox(scale, defaultState, action) highlightColor = framework.color.hoverColor if framework.PointIsInRect(x, y, self:Geometry()) then checkbox:SetChecked(not checked) - action(checkbox, checked) end end ), @@ -37,9 +35,9 @@ function framework:CheckBox(scale, defaultState, action) checked = newChecked unhighlightedColor = (checked and framework.color.selectedColor) or framework.stroke.defaultBorder rect:SetDecorations({ (isInside and highlightColor) or unhighlightedColor }) + action(checkbox, checked) end - checkbox:SetChecked(checked) - action(checkbox, checked) + checkbox:SetChecked(defaultState) return checkbox -end \ No newline at end of file +end From cb3714471817116ec71c3d4b9ecab38881807943 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Tue, 2 Sep 2025 20:39:45 -0400 Subject: [PATCH 3/3] Revert "move action to setChecked" This reverts commit 5f1b37273b609c3ccec52d2cf458f6678d0673a0. --- MasterFramework Dev/Framework/Controls/CheckBox.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MasterFramework Dev/Framework/Controls/CheckBox.lua b/MasterFramework Dev/Framework/Controls/CheckBox.lua index b62d760..f5ba744 100644 --- a/MasterFramework Dev/Framework/Controls/CheckBox.lua +++ b/MasterFramework Dev/Framework/Controls/CheckBox.lua @@ -2,7 +2,8 @@ function framework:CheckBox(scale, defaultState, action) local checkbox local dimension = framework:AutoScalingDimension(scale) local radius = framework:AutoScalingDimension(scale / 2) - local checked + + local checked = defaultState local highlightColor = framework.color.hoverColor local unhighlightedColor = framework.stroke.defaultBorder @@ -23,6 +24,7 @@ function framework:CheckBox(scale, defaultState, action) highlightColor = framework.color.hoverColor if framework.PointIsInRect(x, y, self:Geometry()) then checkbox:SetChecked(not checked) + action(checkbox, checked) end end ), @@ -35,9 +37,9 @@ function framework:CheckBox(scale, defaultState, action) checked = newChecked unhighlightedColor = (checked and framework.color.selectedColor) or framework.stroke.defaultBorder rect:SetDecorations({ (isInside and highlightColor) or unhighlightedColor }) - action(checkbox, checked) end - checkbox:SetChecked(defaultState) + checkbox:SetChecked(checked) + action(checkbox, checked) return checkbox -end +end \ No newline at end of file