Skip to main content

caret_blink

Function caret_blink 

Source
pub fn caret_blink(
    tracker: Res<'_, FocusTracker>,
    inputs: Query<'_, '_, (), With<TextInput>>,
    changed_inputs: Query<'_, '_, (), Changed<TextInput>>,
    blink: ResMut<'_, CaretBlink>,
    animations: Option<Res<'_, AnimationsActive>>,
    frame_dirty: Option<ResMut<'_, FrameDirty>>,
    last_focused: Local<'_, Option<Entity>>,
)
Expand description

Caret blink driver (W2 Qt-polish: text-editing core).

While a TextInput entity holds keyboard focus:

  • toggles CaretBlink::visible every CaretBlink::period (~530 ms, Qt’s cadence),
  • resets the phase to visible whenever the focused input’s TextInput state changes (any edit or caret/selection move - the keystroke router and the mirror both write those fields in lockstep with the buffer) or focus moves to a different entity,
  • marks FrameDirty on each toggle so the backend re-encodes, and
  • raises AnimationsActive so the redraw scheduler keeps ticking between OS events (same self-scheduling contract the hover/press tweens use).

When no text input is focused the system requests nothing: the flag stays untouched at visible, AnimationsActive is not raised, and the app reaches full idle quiescence (zero blink wakeups).