From 7e117809b2f975e4ba0a47e2e9bcc759312eed51 Mon Sep 17 00:00:00 2001 From: Sam Sung <51686767+samwhosung@users.noreply.github.com> Date: Wed, 30 Sep 2026 19:18:52 +0700 Subject: [PATCH] /errors: the selected error is copyable, in a read-only EditBox (#730) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `/errors` showed the selected error in a FontString, so a player could not select or copy the message and traceback they came to report. The detail pane now hosts a multi-line EditBox the way stock `MailFrame.xml` hosts the mail body: - `autoFocus="false"`, so the keyboard stays with the game until a click; - Escape clears focus; - a mouse-enabled scroll child that focuses the box on a click below its text; - `ScrollingEdit_OnTextChanged` for the range, since the box is as tall as its text. The box is read-only: an edit is undone on `OnTextChanged`. Focus selects all, so Ctrl+C copies the whole error, and a new error arriving keeps the selection. The text keeps its font, its 6/6 inset and its 270 wrap. Tests cover the whole text in the box, the undone edits, select-all and copy, a click below the text, Escape, and the range over a long traceback. Fixes #703 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 5.5 --- .../benilla-app/assets/ui/ScriptLogFrame.xml | 66 +++- .../benilla-app/src/ui_script/layer_tests.rs | 318 +++++++++++++++++- 2 files changed, 367 insertions(+), 17 deletions(-) diff --git a/crates/benilla-app/assets/ui/ScriptLogFrame.xml b/crates/benilla-app/assets/ui/ScriptLogFrame.xml index d12319a8..9a2abc30 100644 --- a/crates/benilla-app/assets/ui/ScriptLogFrame.xml +++ b/crates/benilla-app/assets/ui/ScriptLogFrame.xml @@ -127,7 +127,10 @@ BenillaScriptLog_UpdateDetail() end - -- The selected message in full, traceback and all. + -- The selected message in full, traceback and all, in a box a player can select and copy + -- from. A text that has not changed is left alone: `SetText` collapses the selection, so a + -- new error arriving must not undo one about to be copied. A different text takes the + -- keyboard from the box, as a click on another row does. function BenillaScriptLog_UpdateDetail() local text = "" if BenillaScriptLogSelected then @@ -141,12 +144,24 @@ if text == "" then text = "Select a row above to read it in full." end - getglobal("BenillaScriptLogDetailText"):SetText(text) + local box = getglobal("BenillaScriptLogDetailText") + if text ~= box.shown then + box.shown = text + box:ClearFocus() + box:SetText(text) + end end - -- Text rects resolve after Lua runs, so the detail child is re-measured every frame. - function BenillaScriptLogFrame_OnUpdate() - BenillaScroll_ResizeChild("BenillaScriptLogDetailScroll", { "BenillaScriptLogDetailText" }) + -- The box is read-only: a player's edit is undone. The restore's own `SetText` raises + -- another change, which finds the text equal and stops; `SetText` of an equal text does + -- nothing. The selection an edit replaced is put back, so Ctrl+C still copies it all. + function BenillaScriptLogDetail_OnTextChanged() + local shown = this.shown or "" + if this:GetText() ~= shown then + this:SetText(shown) + this:HighlightText() + end + ScrollingEdit_OnTextChanged(getglobal("BenillaScriptLogDetailScroll")) end function BenillaScriptLogRow_OnClick(button) @@ -304,18 +319,38 @@ BenillaScrollBar_OnValueChanged(this, arg1) - + + - - - - - - - - - + + + + + + + + BenillaScriptLogDetail_OnTextChanged() + this:HighlightText() + this:ClearFocus() + + + + + + BenillaScriptLogDetailText:SetFocus() + @@ -338,7 +373,6 @@ BenillaScriptLogFrame_OnMouseWheel(arg1) BenillaScriptLog_Update() - BenillaScriptLogFrame_OnUpdate()