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()