Skip to content

Fix caret behavior on input field activation#2850

Open
pvcraven wants to merge 1 commit intodevelopmentfrom
pvcraven/text_fix
Open

Fix caret behavior on input field activation#2850
pvcraven wants to merge 1 commit intodevelopmentfrom
pvcraven/text_fix

Conversation

@pvcraven
Copy link
Copy Markdown
Member

@pvcraven pvcraven commented May 7, 2026

Summary

Fix UIInputText caret not activating when switching between input fields.

Description

_on_active_changed only handled deactivation (_activeFalse), ignoring activation (_activeTrue). This meant caret.on_activate() was never called through the Property callback path.

The normal activation path is: click → on_clickactivate(). But UIInteractiveWidget.on_event calls _grap_active() on mouse press, setting widget._active = True before on_click fires on mouse release. When activate() runs, its if self._active: return guard bails out immediately — caret.on_activate() is never reached.

The caret appears to work on first use because pyglet's Caret constructor defaults _active = True. After the first deactivate() sets caret._active = False, no code path restores it.

The fix adds the activation case to _on_active_changed, so the caret is properly activated whenever the widget's _active property becomes True, regardless of whether it was set by activate() or _grap_active().

Test plan

  • Place two or more UIInputText widgets on screen
  • Click between them repeatedly — caret should remain visible and blinking in the focused field

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