diff --git a/backends/roblox/imgui_impl_roblox.lua b/backends/roblox/imgui_impl_roblox.lua index 6e7c401..8ffac63 100644 --- a/backends/roblox/imgui_impl_roblox.lua +++ b/backends/roblox/imgui_impl_roblox.lua @@ -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.) diff --git a/build/ImGui.linemap.json b/build/ImGui.linemap.json index 9d2185c..89d433a 100644 --- a/build/ImGui.linemap.json +++ b/build/ImGui.linemap.json @@ -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"]] \ No newline at end of file +[[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"]] \ No newline at end of file diff --git a/build/ImGui.luau b/build/ImGui.luau index 3365e6c..6e18070 100644 --- a/build/ImGui.luau +++ b/build/ImGui.luau @@ -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.) diff --git a/tools/test/scripts/t_textproxy.luau b/tools/test/scripts/t_textproxy.luau index 3d9c53c..b7020b6 100644 --- a/tools/test/scripts/t_textproxy.luau +++ b/tools/test/scripts/t_textproxy.luau @@ -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)