PlatformImeData: IME position + SelectedText for Roblox text proxy; bump core

This commit is contained in:
4DBug committed 2026-10-17 04:25:28 -05:00
1 parent 4ade176b90
commit 7190f1c983
3 files changed
+54 -2

No files matched your search

+13 -1
View File
@@ -2954,7 +2954,19 @@ return function(G)
queue:resize(0)
end
-- [Port] TODO: PlatformImeData (IME position)
-- notify OS of text input position for IME (and, in the port, the selected text for the Roblox text proxy)
if not readOnly then
local ime = ImGui.GetCurrentContext().PlatformImeData
ime.WantVisible = true
ime.WantTextInput = true
-- at the main cursor: the top left of its line (as in Dear ImGui's InputText)
local row, column = self:docPos2VisPos(self:getCursorPosition(cursors:getMainIndex()))
ime.InputPos = ImVec2(self.cursorScreenPos.x + self.textLeftOffset + column * self.glyphSize.x - 1, self.cursorScreenPos.y + row * self.glyphSize.y)
ime.InputLineHeight = self.glyphSize.y
local viewport = ImGui.GetCurrentWindow().Viewport
if viewport then ime.ViewportId = viewport.ID end
ime.SelectedText = self:GetSelectedText() or ""
end
-- tell app to ignore keyboard inputs
ImGui.SetNextFrameWantCaptureKeyboard(true)
+40
View File
@@ -0,0 +1,40 @@
-- Roblox text proxy: the editor's selection is mirrored into the proxy TextBox, and proxy typing is inserted.
local RS = game:GetService("ReplicatedStorage")
local G = require(RS:WaitForChild("ImGui"))
local TextEditor = require(RS:WaitForChild("TextEditor"))(G)
local ImGui, ImVec2 = G.ImGui, G.ImVec2
ImGui.CreateContext()
G.ImGui_ImplRoblox.Init()
G.ImGui_ImplRoblox.SetTextProxy(true)
local io = ImGui.GetIO()
local editor = TextEditor.new()
editor:SetText("hello world")
local proxy
local frame = 0
game:GetService("RunService").Stepped:Connect(function()
frame += 1
if frame > 30 then return end
G.ImGui_ImplRoblox.NewFrame()
io.DeltaTime = 1 / 60
proxy = proxy or game:GetService("Players").LocalPlayer.PlayerGui.ImGui.TextProxy
if frame == 5 then io:AddMousePosEvent(400, 60) end
if frame == 6 then io:AddMouseButtonEvent(0, true) end
if frame == 7 then io:AddMouseButtonEvent(0, false) end
if frame == 9 then editor:SelectAll() end
if frame == 16 then proxy.Text = "bye" end
ImGui.NewFrame()
ImGui.SetNextWindowPos(ImVec2(0, 0))
ImGui.SetNextWindowSize(ImVec2(600, 400))
ImGui.Begin("Editor")
editor:Render("##editor")
ImGui.End()
ImGui.Render()
G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData())
if frame == 14 then assert(proxy.Text == "hello world", "mirror: " .. proxy.Text) end
if frame == 25 then
assert(editor:GetText() == "bye\n", "inserted: " .. editor:GetText())
print("OK")
end
end)