Skip to content

Commit 45f2e6b

Browse files
committed
debounce fixes!
1 parent 72cac62 commit 45f2e6b

2 files changed

Lines changed: 30 additions & 10 deletions

File tree

src/libs/gui.luau

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -709,13 +709,14 @@ end
709709

710710
--// Pushes commands on navigation stack
711711
function guiModule:pushCommands(commands)
712-
-- Guard against the key that triggered this push leaking into the textbox
713-
guiModule._inputSubmitGuardUntil = os.clock() + 0.08
712+
-- Guard against the key that triggered this push leaking into the textbox!
713+
guiModule._inputSubmitGuardUntil = os.clock() + 0.14
714714

715715
local textBox = guiModule.guiElements.Gui.Input and guiModule.guiElements.Gui.Input:FindFirstChild("TextBox")
716716

717717
if textBox then
718718
textBox:ReleaseFocus()
719+
textBox.Text = ""
719720
end
720721

721722
-- Insert registered commands into the stack
@@ -732,29 +733,30 @@ function guiModule:pushCommands(commands)
732733
-- get the selected command
733734
guiModule.selectedCommand = 1
734735

735-
-- Reset text safely
736-
if textBox then
737-
textBox.Text = ""
736+
guiModule:rebuildUI()
738737

739-
task.defer(function()
738+
-- Refocus only after the originating Enter is definitely gone
739+
if textBox then
740+
task.delay(0.14, function()
740741
if not textBox.Parent then
741742
return
742743
end
743744

745+
textBox.Text = ""
744746
textBox:CaptureFocus()
745747

746748
task.defer(function()
747749
if not textBox.Parent then
748750
return
749751
end
750752

751-
textBox.Text = ""
753+
-- Hard clear in case Roblox injected a stray character
754+
if os.clock() < guiModule._inputSubmitGuardUntil + 0.03 then
755+
textBox.Text = ""
756+
end
752757
end)
753758
end)
754759
end
755-
756-
-- finally, we rebuild
757-
guiModule:rebuildUI()
758760
end
759761

760762
--// Pops navigation stack commands

src/libs/input.luau

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ local SetBinds = {
1313
"F"
1414
}
1515

16+
--// Enter guard
17+
local returnHeld = false
18+
local lastReturnTime = 0
19+
1620
--// Hold connection for arrow keys
1721
local holdConnection = nil
1822

@@ -150,6 +154,18 @@ function InputModule:startModule(plugin : Plugin)
150154
return
151155
end
152156

157+
if returnHeld then
158+
return
159+
end
160+
161+
-- Return held checks
162+
returnHeld = true
163+
local now = os.clock()
164+
if now - lastReturnTime < 0.18 then
165+
return
166+
end
167+
lastReturnTime = now
168+
153169
-- Enter/activate callback()
154170
guiModule:activateSelected()
155171
end
@@ -166,6 +182,8 @@ function InputModule:startModule(plugin : Plugin)
166182
UserInputService.InputEnded:Connect(function(input)
167183
if input.KeyCode == Enum.KeyCode.Up or input.KeyCode == Enum.KeyCode.Down then
168184
cancelHold()
185+
elseif input.KeyCode == Enum.KeyCode.Return then
186+
returnHeld = false
169187
end
170188
end)
171189
end

0 commit comments

Comments
 (0)