Build & Release / build (push) Canceled after 0s
- TextProxy works for any widget that sets PlatformImeData.WantTextInput (+ SelectedText) - TextProxy: key-code fallback waits for the TextBox (fixes doubled typing); no stuck Ctrl after paste - Raster: reversed rects (min > max) draw like upstream (fixes ImNodes/ImPlot box select) - test harness: --module NAME=path loads extra ModuleScripts - new tests: t_textproxy_custom, t_rect_flip - extensions/: submodules for imguicolortextedit-luau, imguizmo-luau, implot-luau, implot3d-luau, imnodes-luau
32 lines
1.5 KiB
Luau
32 lines
1.5 KiB
Luau
-- Text proxy for a custom widget (no ActiveId): it sets PlatformImeData.WantTextInput/SelectedText while its window is focused.
|
|
local G = require(game:GetService("ReplicatedStorage"):WaitForChild("ImGui"))
|
|
local ImGui, ImVec2 = G.ImGui, G.ImVec2
|
|
local UIS = game:GetService("UserInputService")
|
|
ImGui.CreateContext(); G.ImGui_ImplRoblox.Init(); G.ImGui_ImplRoblox.SetTextProxy(true)
|
|
local io = ImGui.GetIO()
|
|
local got, proxy, f = "", nil, 0
|
|
game:GetService("RunService").Stepped:Connect(function()
|
|
f += 1
|
|
G.ImGui_ImplRoblox.NewFrame()
|
|
proxy = proxy or game:GetService("Players").LocalPlayer.PlayerGui.ImGui.TextProxy
|
|
if f == 3 then io:AddMousePosEvent(60, 45); io:AddMouseButtonEvent(0, true) end
|
|
if f == 4 then io:AddMouseButtonEvent(0, false) end
|
|
if f == 8 then assert(UIS:GetFocusedTextBox() == proxy, "proxy focused"); proxy.Text = "x" end
|
|
ImGui.NewFrame()
|
|
ImGui.SetNextWindowPos(ImVec2(10, 10)); ImGui.SetNextWindowSize(ImVec2(300, 100))
|
|
ImGui.Begin("Editor")
|
|
if ImGui.IsWindowFocused() then
|
|
local ime = ImGui.GetCurrentContext().PlatformImeData
|
|
ime.WantTextInput = true; ime.SelectedText = "abc"
|
|
local q = io.InputQueueCharacters
|
|
for i = 1, q.Size do got ..= utf8.char(q.Data[i]) end
|
|
end
|
|
ImGui.End()
|
|
ImGui.Render(); G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
|
|
if f == 12 then
|
|
assert(got == "x", "widget got: " .. got)
|
|
assert(proxy.Text == "abc", "mirror: " .. proxy.Text)
|
|
print("CUSTOM PROXY OK")
|
|
end
|
|
end)
|