Skip to content

Entry: a click places the caret in widget-local coordinates - #485

Merged
tannevaled merged 1 commit into
mainfrom
entry-click-local
Oct 8, 2026
Merged

tannevaled merged 1 commit into
mainfrom
entry-click-local

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Entry.OnEvent mapped a click to a caret position with ev.X - (e.Bounds().X + pad). But ev.X is already widget-local (the package convention; translateEvent delivers it that way), so the Entry's own X was subtracted twice. Any Entry not at the surface's left edge (that is, every Entry in a form) put the caret at 0 on a click, and typing went in front of the existing value. SearchEntry already does it right (ev.X-(padX+iconW)+s.scrollX).

  • fix: ev.X - pad + e.scrollX
  • TestEntryClickPositionsCaret encoded the bug: it clicked a lone Entry at a surface x. It now clicks at a local x.
  • new TestEntryClickThroughAContainer: an Entry inside an HBox at (30, 40), clicked through the box, then typed into. It fails without the fix (caret at 0), passes with it.

Package coverage still 100% locally.

Found by the go-fft WASM playground's browser checks: clicking its N field (showing 1000) and typing 1009 produced 1001000.

🤖 Generated with Claude Code

OnEvent's X is widget-local, the package convention and what every
container delivers. Entry subtracted its own Bounds().X from it a second
time, so in any form (an Entry not at the surface's left edge) a click
put the caret at 0 and the next keystrokes went in front of the old
value. SearchEntry already did it right.

TestEntryClickPositionsCaret encoded the bug (it clicked at a surface x
on a lone Entry); it now clicks locally. TestEntryClickThroughAContainer
clicks through an HBox and types: it fails without the fix (caret 0).

Found by the go-fft playground's browser protocol: typing a length into
its N field produced 1001000 instead of 1009.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 1f0a49d into main Oct 8, 2026
1 check passed
@tannevaled
tannevaled deleted the entry-click-local branch October 8, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant