Skip to main content

apply_text_bindings

Function apply_text_bindings 

Source
pub fn apply_text_bindings(
    store: Res<'_, PropertyStore>,
    q: Query<'_, '_, (&BindText, &mut TextContent, Option<&mut TextInput>), (Without<Focused>, Without<ImeState>)>,
    new_binds: Query<'_, '_, (), Added<BindText>>,
)
Expand description

Copies PropertyStore[Global(name)] into TextContent for every BindText entity. Entities whose property has no entry keep their existing text.

Editing-protection gate: entities currently carrying Focused or an active ImeState preedit are skipped - overwriting TextContent mid-edit would race the keystroke / IME path in [crate::input::route_ime_events] and lumen_input::type_into_focused, wiping the user’s in-progress typing or leaving the caret dangling past the new (shorter) string. When apply_text_bindings does overwrite an unfocused entity, any co-resident [TextInput.cursor] is clamped to <= new_text.len() so the cursor cannot point past the buffer end.