TextProxy: key-code fallback waits a few frames for the TextBox (fixes doubled typing)
Build & Release / build (push) Canceled after 0s

This commit is contained in:
4DBug committed 2026-10-17 07:00:27 -05:00
1 parent 4bee0e493a
commit e1c4ea96d7
4 files changed
+24 -8

No files matched your search

+11 -3
View File
@@ -379,9 +379,17 @@ function ImGui_ImplRoblox_NewFrame()
BackendData.DeleteKeySeen = false
local pending = BackendData.PendingChars
if #pending > 0 then
if not used_proxy_text then for _, c in ipairs(pending) do io:AddInputCharacter(c) end end
table.clear(pending)
if used_proxy_text then
table.clear(pending) -- the proxy delivered the text: the key-code copies would double it
BackendData.PendingAge = 0
elseif #pending > 0 then
-- the TextBox's Text can update a frame or two after InputBegan: wait before falling back to key codes
BackendData.PendingAge = (BackendData.PendingAge or 0) + 1
if not ProxyFocused or BackendData.PendingAge > 3 then
for _, c in ipairs(pending) do io:AddInputCharacter(c) end
table.clear(pending)
BackendData.PendingAge = 0
end
end
-- Tiles Active while over imgui, so Roblox stops passing clicks/wheel to the game (camera zoom etc.)
+1 -1
View File
@@ -1 +1 @@
[[46, "imgui.lua"], [22648, "imgui_demo.lua"], [34505, "imgui_draw.lua"], [42835, "imgui_h.lua"], [45838, "roblox/raster.lua"], [46314, "roblox/textures.lua"], [46485, "roblox/layers.lua"], [46822, "roblox/overlays.lua"], [46903, "roblox/render.lua"], [47748, "roblox/parallel.lua"], [48147, "imgui_impl_roblox.lua"], [48636, "imgui_impl_roblox_fonts.lua"], [55039, "imgui_internal.lua"], [59005, "imgui_tables.lua"], [64097, "imgui_widgets.lua"], [76335, "imstb_rectpack.lua"], [76999, "imstb_textedit.lua"], [78541, "imstb_truetype.lua"], [81329, "imstd_minstdio.lua"]]
[[46, "imgui.lua"], [22648, "imgui_demo.lua"], [34505, "imgui_draw.lua"], [42835, "imgui_h.lua"], [45838, "roblox/raster.lua"], [46314, "roblox/textures.lua"], [46485, "roblox/layers.lua"], [46822, "roblox/overlays.lua"], [46903, "roblox/render.lua"], [47748, "roblox/parallel.lua"], [48147, "imgui_impl_roblox.lua"], [48644, "imgui_impl_roblox_fonts.lua"], [55047, "imgui_internal.lua"], [59013, "imgui_tables.lua"], [64105, "imgui_widgets.lua"], [76343, "imstb_rectpack.lua"], [77007, "imstb_textedit.lua"], [78549, "imstb_truetype.lua"], [81337, "imstd_minstdio.lua"]]
+11 -3
View File
@@ -48525,9 +48525,17 @@ function ImGui_ImplRoblox_NewFrame()
BackendData.DeleteKeySeen = false
local pending = BackendData.PendingChars
if #pending > 0 then
if not used_proxy_text then for _, c in ipairs(pending) do io:AddInputCharacter(c) end end
table.clear(pending)
if used_proxy_text then
table.clear(pending) -- the proxy delivered the text: the key-code copies would double it
BackendData.PendingAge = 0
elseif #pending > 0 then
-- the TextBox's Text can update a frame or two after InputBegan: wait before falling back to key codes
BackendData.PendingAge = (BackendData.PendingAge or 0) + 1
if not ProxyFocused or BackendData.PendingAge > 3 then
for _, c in ipairs(pending) do io:AddInputCharacter(c) end
table.clear(pending)
BackendData.PendingAge = 0
end
end
-- Tiles Active while over imgui, so Roblox stops passing clicks/wheel to the game (camera zoom etc.)
+1 -1
View File
@@ -64,7 +64,7 @@ game:GetService("RunService").Stepped:Connect(function()
assert(st.TextLen == 0, "backspace should delete imgui's whole selection, len " .. st.TextLen)
print("BACKSPACE OK")
end
if f == 27 then
if f == 30 then -- (key-code fallback waits a few frames for the TextBox first)
local st = ImGui.GetCurrentContext().InputTextState
local got = G.ImGui._ByteArrayToString(st.TextA.Data, 1, st.TextLen + 1)
assert(got:find("z"), "key fallback while proxy focused: " .. got)