0.4.1
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
This commit is contained in:
4DBug committed 2026-10-17 07:31:40 -05:00
1 parent c5a0b20132
commit e2d1cf5cf9
24 files changed
+291 -46

No files matched your search

+1 -1
View File
@@ -1 +1 @@
[[46, "imgui.lua"], [22647, "imgui_demo.lua"], [34504, "imgui_draw.lua"], [42828, "imgui_h.lua"], [45827, "roblox/raster.lua"], [46303, "roblox/textures.lua"], [46474, "roblox/layers.lua"], [46811, "roblox/overlays.lua"], [46892, "roblox/render.lua"], [47737, "roblox/parallel.lua"], [48136, "imgui_impl_roblox.lua"], [48623, "imgui_impl_roblox_fonts.lua"], [55026, "imgui_internal.lua"], [58992, "imgui_tables.lua"], [64084, "imgui_widgets.lua"], [76318, "imstb_rectpack.lua"], [76982, "imstb_textedit.lua"], [78524, "imstb_truetype.lua"], [81312, "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"], [48648, "imgui_impl_roblox_fonts.lua"], [55051, "imgui_internal.lua"], [59017, "imgui_tables.lua"], [64109, "imgui_widgets.lua"], [76347, "imstb_rectpack.lua"], [77011, "imstb_textedit.lua"], [78553, "imstb_truetype.lua"], [81341, "imstd_minstdio.lua"]]
+48 -19
View File
@@ -14418,6 +14418,7 @@ function ImGui.NewFrame()
ImGuiPlatformImeData_Copy(g.PlatformImeDataPrev, g.PlatformImeData)
g.PlatformImeData.WantVisible = false
g.PlatformImeData.WantTextInput = false
g.PlatformImeData.SelectedText = "" -- [Port]
-- Mouse wheel scrolling, scale
ImGui.UpdateMouseWheel()
@@ -40648,6 +40649,10 @@ function MT.ImDrawList:AddRect(p_min, p_max, col, rounding, thickness, flags)
return
end
-- [Port] reversed corners (min > max, e.g. a box selection dragged up/left): upstream's min_dim checks drop them, older ImGui drew them
if p_min.x > p_max.x or p_min.y > p_max.y then
p_min, p_max = ImVec2(ImMin(p_min.x, p_max.x), ImMin(p_min.y, p_max.y)), ImVec2(ImMax(p_min.x, p_max.x), ImMax(p_min.y, p_max.y))
end
flags = bit32.bor(flags, self.Flags)
local stroke_pos = _GetStrokePos(flags, 131072 --[[ImDrawFlags.StrokeInside]])
if stroke_pos == 917504 --[[ImDrawFlags.StrokeLegacy]] then
@@ -40865,6 +40870,8 @@ function MT.ImDrawList:AddRectFilled(p_min, p_max, col, rounding, flags)
end
local ax, ay, bx, by = p_min.x, p_min.y, p_max.x, p_max.y
if ax > bx then ax, bx = bx, ax end -- [Port] reversed corners: see AddRect
if ay > by then ay, by = by, ay end
local width = bx - ax
local height = by - ay
local min_dim = ImMin(width, height)
@@ -44265,6 +44272,7 @@ end
--- @field InputPos ImVec2
--- @field InputLineHeight float
--- @field ViewportId ImGuiID
--- @field SelectedText string
--- @return ImGuiPlatformImeData
--- @nodiscard
@@ -44274,7 +44282,8 @@ function ImGuiPlatformImeData()
WantTextInput = false, -- A widget wants text input, not necessarily IME to be visible. This is automatically set to the upcoming value of io.WantTextInput.
InputPos = ImVec2(), -- Position of input cursor (for IME).
InputLineHeight = 0.0, -- Line height (for IME).
ViewportId = 0 -- ID of platform window/viewport.
ViewportId = 0, -- ID of platform window/viewport.
SelectedText = "" -- [Port] Text currently selected in the widget wanting text input (backends may mirror it, e.g. for native copy).
}
end
@@ -44286,6 +44295,7 @@ function ImGuiPlatformImeData_Copy(dest, src)
ImVec2_Copy(dest.InputPos, src.InputPos)
dest.InputLineHeight = src.InputLineHeight
dest.ViewportId = src.ViewportId
dest.SelectedText = src.SelectedText -- [Port]
end
--- @param data1 ImGuiPlatformImeData
@@ -44295,7 +44305,8 @@ function ImGuiPlatformImeData_Compare(data1, data2)
data1.WantTextInput ~= data2.WantTextInput or
data1.InputPos ~= data2.InputPos or
data1.InputLineHeight ~= data2.InputLineHeight or
data1.ViewportId ~= data2.ViewportId then
data1.ViewportId ~= data2.ViewportId or
data1.SelectedText ~= data2.SelectedText then
return false
end
@@ -48386,9 +48397,13 @@ function ImGui_ImplRoblox_SetTextProxy(enabled)
BackendData.ProxyLostId = nil
return
end
BackendData.ProxyLostId = BackendData.ProxyActiveId
BackendData.ProxyLostId = BackendData.ProxyActiveId -- don't recapture for the same field
local g = ImGui.GetCurrentContext()
if g and g.ActiveId ~= 0 and g.ActiveId == BackendData.ProxyActiveId then ImGui.ClearActiveID() end
if g and g.ActiveId ~= 0 and g.ActiveId == BackendData.ProxyActiveId then
ImGui.ClearActiveID()
-- the key falls back to the focused window next: the "don't recapture" covers it too
if g.NavWindow then BackendData.ProxyActiveId = g.NavWindow.ID; BackendData.ProxyLostId = g.NavWindow.ID end
end
end)
end
@@ -48442,14 +48457,18 @@ function ImGui_ImplRoblox_NewFrame()
local proxy = BackendData.Proxy
local g = ImGui.GetCurrentContext()
local focused_box = proxy and UserInputService:GetFocusedTextBox()
-- key: the active item (InputText), else the focused window (custom widgets setting PlatformImeData.WantTextInput)
local proxy_key = g.ActiveId
if proxy_key == 0 and g.NavWindow then proxy_key = g.NavWindow.ID end
if proxy_key ~= BackendData.ProxyActiveId then BackendData.ProxyLostId = nil end -- (a "don't recapture" never outlives its field)
if not proxy then
elseif io.WantTextInput and g.ActiveId ~= 0 then
if g.ActiveId ~= BackendData.ProxyActiveId or g.ActiveIdIsJustActivated or g.IO.MouseClicked[0] then
BackendData.ProxyActiveId = g.ActiveId
elseif io.WantTextInput and proxy_key ~= 0 then
if proxy_key ~= BackendData.ProxyActiveId or (g.ActiveId ~= 0 and g.ActiveIdIsJustActivated) or g.IO.MouseClicked[0] then
BackendData.ProxyActiveId = proxy_key
BackendData.ProxyLostId = nil
end
local mouse_up = not (io.MouseDown[0] or io.MouseDown[1] or io.MouseDown[2])
if focused_box ~= proxy and mouse_up and BackendData.ProxyLostId ~= g.ActiveId
if focused_box ~= proxy and mouse_up and BackendData.ProxyLostId ~= proxy_key and proxy.Parent
and (focused_box == nil or not focused_box:IsDescendantOf(game)) then
-- what it already holds is not new input (else re-typing it would collapse imgui's selection)
BackendData.ProxyText = proxy.Text
@@ -48487,17 +48506,15 @@ function ImGui_ImplRoblox_NewFrame()
for _, cp in utf8.codes(text:sub(#prev + 1)) do io:AddInputCharacter(cp) end
end
end
if ctrl then io:AddKeyEvent(4096 --[[ImGuiMod_Ctrl]], true) end
-- re-press only if still physically held: the text can arrive after Ctrl's InputEnded, and re-pressing
-- then left Ctrl stuck down in imgui (typing ignored, shortcuts broken until Ctrl was pressed again)
if ctrl and (UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) or UserInputService:IsKeyDown(Enum.KeyCode.RightControl)) then
io:AddKeyEvent(4096 --[[ImGuiMod_Ctrl]], true)
end
used_proxy_text = true
BackendData.ProxyText = nil
end
local st = g.InputTextState
local sel = ""
if st and st.ID ~= 0 and st.ID == g.ActiveId and st.Stb and st:HasSelection() then
local a, b = math.min(st.Stb.select_start, st.Stb.select_end),
math.max(st.Stb.select_start, st.Stb.select_end)
sel = ImGui._ByteArrayToString(st.TextA.Data, a, b) -- stb positions are 1-based in this port
end
local sel = g.PlatformImeData.SelectedText or "" -- (last frame's widget selection: ImGui.NewFrame() not run yet)
if sel ~= BackendData.ProxyText then
proxy.Text = sel
BackendData.ProxyLastRaw = nil
@@ -48512,9 +48529,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.)
@@ -70491,6 +70516,10 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback
ImVec2_Copy(ime_data.InputPos, ImVec2(cursor_screen_pos.x - 1.0, cursor_screen_pos.y - g.FontSize))
ime_data.InputLineHeight = g.FontSize
ime_data.ViewportId = window.Viewport.ID
-- [Port] selection for backends (stb positions are 1-based in this port)
if state.Stb and state:HasSelection() then
ime_data.SelectedText = ImGui._ByteArrayToString(state.TextA.Data, ImMin(state.Stb.select_start, state.Stb.select_end), ImMax(state.Stb.select_start, state.Stb.select_end))
end
end
end
+1 -1
View File
@@ -1 +1 @@
[[183, "imgui.lua"], [22784, "imgui_demo.lua"], [34641, "imgui_draw.lua"], [42965, "imgui_h.lua"], [45962, "imgui_impl_love.lua"], [46506, "imgui_internal.lua"], [50472, "imgui_tables.lua"], [55564, "imgui_widgets.lua"], [67798, "imstb_rectpack.lua"], [68462, "imstb_textedit.lua"], [70004, "imstb_truetype.lua"], [72792, "imstd_minstdio.lua"]]
[[183, "imgui.lua"], [22785, "imgui_demo.lua"], [34642, "imgui_draw.lua"], [42972, "imgui_h.lua"], [45973, "imgui_impl_love.lua"], [46517, "imgui_internal.lua"], [50483, "imgui_tables.lua"], [55575, "imgui_widgets.lua"], [67813, "imstb_rectpack.lua"], [68477, "imstb_textedit.lua"], [70019, "imstb_truetype.lua"], [72807, "imstd_minstdio.lua"]]
+17 -2
View File
@@ -14555,6 +14555,7 @@ function ImGui.NewFrame()
ImGuiPlatformImeData_Copy(g.PlatformImeDataPrev, g.PlatformImeData)
g.PlatformImeData.WantVisible = false
g.PlatformImeData.WantTextInput = false
g.PlatformImeData.SelectedText = "" -- [Port]
-- Mouse wheel scrolling, scale
ImGui.UpdateMouseWheel()
@@ -40785,6 +40786,10 @@ function MT.ImDrawList:AddRect(p_min, p_max, col, rounding, thickness, flags)
return
end
-- [Port] reversed corners (min > max, e.g. a box selection dragged up/left): upstream's min_dim checks drop them, older ImGui drew them
if p_min.x > p_max.x or p_min.y > p_max.y then
p_min, p_max = ImVec2(ImMin(p_min.x, p_max.x), ImMin(p_min.y, p_max.y)), ImVec2(ImMax(p_min.x, p_max.x), ImMax(p_min.y, p_max.y))
end
flags = bit32.bor(flags, self.Flags)
local stroke_pos = _GetStrokePos(flags, 131072 --[[ImDrawFlags.StrokeInside]])
if stroke_pos == 917504 --[[ImDrawFlags.StrokeLegacy]] then
@@ -41002,6 +41007,8 @@ function MT.ImDrawList:AddRectFilled(p_min, p_max, col, rounding, flags)
end
local ax, ay, bx, by = p_min.x, p_min.y, p_max.x, p_max.y
if ax > bx then ax, bx = bx, ax end -- [Port] reversed corners: see AddRect
if ay > by then ay, by = by, ay end
local width = bx - ax
local height = by - ay
local min_dim = ImMin(width, height)
@@ -44402,6 +44409,7 @@ end
--- @field InputPos ImVec2
--- @field InputLineHeight float
--- @field ViewportId ImGuiID
--- @field SelectedText string
--- @return ImGuiPlatformImeData
--- @nodiscard
@@ -44411,7 +44419,8 @@ function ImGuiPlatformImeData()
WantTextInput = false, -- A widget wants text input, not necessarily IME to be visible. This is automatically set to the upcoming value of io.WantTextInput.
InputPos = ImVec2(), -- Position of input cursor (for IME).
InputLineHeight = 0.0, -- Line height (for IME).
ViewportId = 0 -- ID of platform window/viewport.
ViewportId = 0, -- ID of platform window/viewport.
SelectedText = "" -- [Port] Text currently selected in the widget wanting text input (backends may mirror it, e.g. for native copy).
}
end
@@ -44423,6 +44432,7 @@ function ImGuiPlatformImeData_Copy(dest, src)
ImVec2_Copy(dest.InputPos, src.InputPos)
dest.InputLineHeight = src.InputLineHeight
dest.ViewportId = src.ViewportId
dest.SelectedText = src.SelectedText -- [Port]
end
--- @param data1 ImGuiPlatformImeData
@@ -44432,7 +44442,8 @@ function ImGuiPlatformImeData_Compare(data1, data2)
data1.WantTextInput ~= data2.WantTextInput or
data1.InputPos ~= data2.InputPos or
data1.InputLineHeight ~= data2.InputLineHeight or
data1.ViewportId ~= data2.ViewportId then
data1.ViewportId ~= data2.ViewportId or
data1.SelectedText ~= data2.SelectedText then
return false
end
@@ -61971,6 +61982,10 @@ function ImGui.InputTextEx(label, hint, buf, buf_size, size_arg, flags, callback
ImVec2_Copy(ime_data.InputPos, ImVec2(cursor_screen_pos.x - 1.0, cursor_screen_pos.y - g.FontSize))
ime_data.InputLineHeight = g.FontSize
ime_data.ViewportId = window.Viewport.ID
-- [Port] selection for backends (stb positions are 1-based in this port)
if state.Stb and state:HasSelection() then
ime_data.SelectedText = ImGui._ByteArrayToString(state.TextA.Data, ImMin(state.Stb.select_start, state.Stb.select_end), ImMax(state.Stb.select_start, state.Stb.select_end))
end
end
end