Hey, forum. I’m currently making a UI library and I’m in the last bits of development. I’m trying to make it so when a user presses Tab on their keyboard with one of the TextBox’s focused, it will focus the next TextBox. The issue is that I’m also trying to make it so if either Shift key is pressed, it will focus the previous TextBox, but the Shift input ends when I do that, so it only works for one TextBox and doesn’t stack properly.
Are there any workarounds or fixes? If so, let me know.
if (typeof(self.SpecialKey) == "string") then -- SpecialKey
for i, v in next, Enum.KeyCode:GetEnumItems() do
if (v.Name:sub(math.max(0, #v.Name - #self.SpecialKey) + 1):lower() == self.SpecialKey:lower()) then
table.insert(self.Connections, UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if (input.KeyCode == v) then
self.DoSpecial = true
end
end))
table.insert(self.Connections, UserInputService.InputEnded:Connect(function(input, gameProcessedEvent)
if (input.KeyCode == v) then
self.DoSpecial = false
end
end))
end
end
end
That’s to tell the types if an action should be special or not, in this case, go backwards or go forwards when tabbing between TextBox’s.
table.insert(self.Connections, HueValue:GetPropertyChangedSignal("Text"):Connect(function(): ()
if (HueValue.Text:find("\t")) then
HueValue.Text = HueValue.Text:gsub("\t", "")
if (_self.DoSpecial) then
HueValue:ReleaseFocus()
else
HueValue:ReleaseFocus(); SaturationValue:CaptureFocus()
end
else
if (not Rainbow) then
local Value = tonumber(HueValue.Text)
if (Value) then
HSV(math.clamp(math.floor(Value), 0, 360)/360)
end
end
end
end))
And this is one of the code chunks for one of the TextBox’s, but the tabbing code is the same between all TextBox’s.