exp/textinput: add Field.SetBounds and Field.Handled, process input via internal hook

Replace the per-frame HandleInputWithBounds call with SetBounds (call only
when bounds change) and Handled (query whether input was consumed). Input
processing now runs automatically via an internal hook on before-update,
so users no longer need to drive it every tick.

Deprecate HandleInput and HandleInputWithBounds in favor of the new API.

Closes #3420

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Hajime Hoshi
2026-03-21 22:41:24 +09:00
parent 2dd371fe70
commit b2e88b02ae
2 changed files with 54 additions and 7 deletions
+2 -5
View File
@@ -139,11 +139,8 @@ func (t *TextField) Update() error {
x1 := x0 + 1
y0 := y + cy + py
y1 := y0 + int(fontFace.Metrics().HLineGap+fontFace.Metrics().HAscent+fontFace.Metrics().HDescent)
handled, err := t.field.HandleInputWithBounds(image.Rect(x0, y0, x1, y1))
if err != nil {
return err
}
if handled {
t.field.SetBounds(image.Rect(x0, y0, x1, y1))
if t.field.Handled() {
return nil
}