Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit 166577d

Browse files
committed
Added mouse hover for checkboxes.
1 parent 97a317f commit 166577d

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

src/Workspace/SignsInternal/PluginGui/init.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function PluginGui:newPluginGui(widgetGui)
117117
Color, -- choices array
118118
11 -- the starting index of the selection
119119
)
120-
if GuiUtilities:ShouldUseIconsForDarkerBackgrounds() == true then
120+
if (GuiUtilities:ShouldUseIconsForDarkerBackgrounds()) then
121121
colorTextChoice:SetSelectedIndex(1)
122122
end
123123
colorTextChoice:GetFrame().Parent = textCollapse:GetContentsFrame()

src/Workspace/SignsInternal/StudioWidgets/CustomTextButton.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ function CustomTextButtonClass:_updateButtonVisual()
8484
end
8585
end
8686

87-
-- Backwards compatibility (should be removed in the future)
88-
-- CustomTextButtonClass.getButton = CustomTextButtonClass.GetButton
89-
9087
function CustomTextButtonClass:GetButton()
9188
return self._button
9289
end

src/Workspace/SignsInternal/StudioWidgets/CustomTextLabel.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function CustomTextLabelClass.new(nameSuffix, height)
1919
local label = Instance.new('TextLabel')
2020
label.Text = "Preview"
2121
label.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
22-
if GuiUtilities:ShouldUseIconsForDarkerBackgrounds() == true then
22+
if (GuiUtilities:ShouldUseIconsForDarkerBackgrounds()) then
2323
label.TextColor3 = Color3.fromRGB(255, 255, 255)
2424
end
2525
label.BackgroundTransparency = 1
@@ -32,7 +32,7 @@ function CustomTextLabelClass.new(nameSuffix, height)
3232
local stroke = Instance.new("UIStroke")
3333
stroke.Enabled = false
3434
stroke.Color = Color3.fromRGB(255, 255, 255)
35-
if GuiUtilities:ShouldUseIconsForDarkerBackgrounds() == true then
35+
if (GuiUtilities:ShouldUseIconsForDarkerBackgrounds()) then
3636
stroke.Color = Color3.fromRGB(0, 0, 0)
3737
end
3838
stroke.Parent = label

src/Workspace/SignsInternal/StudioWidgets/LabeledCheckbox.lua

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ local kMinCheckImageSize = UDim2.new(0, kMinCheckImageWidth, 0, kMinCheckImageWi
3131

3232
local kEnabledCheckImage = "rbxasset://textures/DeveloperFramework/checkbox_checked_light.png"
3333
local kDisabledCheckImage = "rbxasset://textures/DeveloperFramework/checkbox_indeterminate_light.png"
34-
local kCheckboxFrameImage = "rbxasset://textures/DeveloperFramework/checkbox_unchecked_hover_light.png"
34+
local kHoverCheckImage = "rbxasset://textures/DeveloperFramework/checkbox_unchecked_hover_light.png"
35+
local kCheckboxFrameImage = "rbxasset://textures/DeveloperFramework/checkbox_unchecked_light.png"
36+
3537
LabeledCheckboxClass = {}
3638
LabeledCheckboxClass.__index = LabeledCheckboxClass
3739

@@ -83,6 +85,10 @@ function LabeledCheckboxClass.new(nameSuffix, labelText, initValue, initDisabled
8385
self._frame = frame
8486
self._button = button
8587
self._label = label
88+
89+
self._clicked = false
90+
self._hovered = false
91+
8692
self._checkImage = checkImage
8793
self._fullBackgroundButton = fullBackgroundButton
8894
self._useDisabledOverride = false
@@ -94,6 +100,21 @@ function LabeledCheckboxClass.new(nameSuffix, labelText, initValue, initDisabled
94100

95101
self:_SetupMouseClickHandling()
96102

103+
-- local function updateImages()
104+
-- if (GuiUtilities:ShouldUseIconsForDarkerBackgrounds()) then
105+
-- kEnabledCheckImage = "rbxasset://textures/DeveloperFramework/checkbox_checked_dark.png"
106+
-- kDisabledCheckImage = "rbxasset://textures/DeveloperFramework/checkbox_indeterminate_dark.png"
107+
-- kHoverCheckImage = "rbxasset://textures/DeveloperFramework/checkbox_unchecked_hover_dark.png"
108+
-- kCheckboxFrameImage = "rbxasset://textures/DeveloperFramework/checkbox_unchecked_dark.png"
109+
--
110+
-- LabeledCheckboxClass:_updateCheckboxVisual()
111+
-- else
112+
-- LabeledCheckboxClass:_updateCheckboxVisual()
113+
-- end
114+
-- end
115+
-- settings().Studio.ThemeChanged:Connect(updateImages)
116+
-- updateImages()
117+
97118
local function updateFontColors()
98119
self:UpdateFontColors()
99120
end
@@ -103,7 +124,6 @@ function LabeledCheckboxClass.new(nameSuffix, labelText, initValue, initDisabled
103124
return self
104125
end
105126

106-
107127
function LabeledCheckboxClass:_MaybeToggleState()
108128
if not self._disabled then
109129
self:SetValue(not self._value)
@@ -112,14 +132,42 @@ end
112132

113133
function LabeledCheckboxClass:_SetupMouseClickHandling()
114134
self._button.MouseButton1Down:Connect(function()
135+
self._clicked = true
115136
self:_MaybeToggleState()
116137
end)
117138

139+
self._fullBackgroundButton.InputBegan:Connect(function(input)
140+
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
141+
self._hovered = true
142+
self:_updateCheckboxVisual()
143+
end
144+
end)
145+
146+
self._fullBackgroundButton.InputEnded:Connect(function(input)
147+
if (input.UserInputType == Enum.UserInputType.MouseMovement) then
148+
self._hovered = false
149+
self._clicked = false
150+
self:_updateCheckboxVisual()
151+
end
152+
end)
153+
118154
self._fullBackgroundButton.MouseButton1Down:Connect(function()
155+
self._clicked = true
156+
self:_updateCheckboxVisual()
119157
self:_MaybeToggleState()
120158
end)
121159
end
122160

161+
function LabeledCheckboxClass:_updateCheckboxVisual()
162+
if (self._clicked) then
163+
self._button.Image = kCheckboxFrameImage
164+
elseif (self._hovered) then
165+
self._button.Image = kHoverCheckImage
166+
else
167+
self._button.Image = kCheckboxFrameImage
168+
end
169+
end
170+
123171
function LabeledCheckboxClass:_HandleUpdatedValue()
124172
self._checkImage.Visible = self:GetValue()
125173

0 commit comments

Comments
 (0)