Preserve text caret after commit
This commit is contained in:
parent
e7ed5dec7d
commit
c1386dee39
2 changed files with 9 additions and 1 deletions
|
|
@ -1069,7 +1069,7 @@ internal sealed class DebugUi
|
|||
if (value != NormalizedValue)
|
||||
{
|
||||
write(value);
|
||||
lastValue = value;
|
||||
SyncCommittedValue(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1183,6 +1183,13 @@ internal sealed class DebugUi
|
|||
selectionAnchor = caretIndex;
|
||||
}
|
||||
|
||||
private void SyncCommittedValue(string value)
|
||||
{
|
||||
lastValue = value;
|
||||
caretIndex = Math.Clamp(caretIndex, 0, value.Length);
|
||||
selectionAnchor = Math.Clamp(selectionAnchor, 0, value.Length);
|
||||
}
|
||||
|
||||
private void MoveCaret(int index, bool selecting)
|
||||
{
|
||||
caretIndex = Math.Clamp(index, 0, NormalizedValue.Length);
|
||||
|
|
|
|||
|
|
@ -67,3 +67,4 @@
|
|||
{"timestamp":"2026-05-12T14:25:00+01:00","topic":"debug-text-editing-capture","lesson":"Debug text boxes need real editing ownership: persistent caret index, selection anchor, mouse placement, drag selection, arrow/Home/End movement, Backspace/Delete, selected-text replacement, and input capture while focused. When a text box owns the keyboard, host-level debug hotkeys and client camera controls must receive a non-interactive input snapshot instead of the live key/mouse state.","files":["src/Aquarium.Engine.Contracts/Input/InputState.cs","src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine/Platform/Win32Window.cs","src/Aquarium.Engine/Render/IAquariumRenderer.cs","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Ui/DebugUi.cs","state/memory.json"],"source":"user text editing requirement"}
|
||||
{"timestamp":"2026-05-12T14:35:00+01:00","topic":"directwrite-text-editing-metrics","lesson":"Do not position text-box caret or selection with guessed monospace character widths. Use DirectWrite text layout hit-test positions for the same font and layout used to draw text, cache those positions for mouse placement, and keep text boxes focus-only visually rather than filling like active buttons on click.","files":["src/Aquarium.Engine/Render/Ui/DebugUi.cs","state/evidence.jsonl"],"source":"user screenshot correction"}
|
||||
{"timestamp":"2026-05-12T14:42:00+01:00","topic":"directwrite-text-editing-vertical-metrics","lesson":"Horizontal caret alignment is not enough. Caret height and selection top/bottom should also come from DirectWrite hit-test metrics for the active glyph run; using the UI line box makes editing visuals droop below the text even when x positions are correct.","files":["src/Aquarium.Engine/Render/Ui/DebugUi.cs","state/evidence.jsonl"],"source":"user screenshot correction"}
|
||||
{"timestamp":"2026-05-12T14:50:00+01:00","topic":"text-edit-commit-state","lesson":"After a text box writes a new bound value, preserve caret and selection against the committed local value immediately. If edit state waits for the next read/sync cycle, the first typed character can leave stale caret state and subsequent input inserts at the wrong position, corrupting commands.","files":["src/Aquarium.Engine/Render/Ui/DebugUi.cs","state/evidence.jsonl"],"source":"terminal input corruption fix"}
|
||||
|
|
|
|||
Loading…
Reference in a new issue