Skip to main content

dispatch_text_input_to_script

Function dispatch_text_input_to_script 

Source
pub fn dispatch_text_input_to_script<H: ScriptHost + Resource<Mutability = Mutable>>(
    host: ResMut<'_, H>,
    edits: MessageReader<'_, '_, TextEditApplied>,
    commits: MessageReader<'_, '_, TextInputCommitted>,
    ids: Query<'_, '_, &LumenId>,
    fields: Query<'_, '_, (Option<&'static TextBuffer>, Option<&'static TextContent>)>,
    out: MessageWriter<'_, ScriptCommandEvent>,
)
Expand description

Forward text changes as on_text_input(id, text).

Fires on every edit that changes the text, which is what a live preview needs, and once more when the field is committed with Enter. An entity gets at most one call per tick: an IME commit both mutates the buffer and raises TextInputCommitted, and the script should see that as one edit, not two.