Skip to main content

dispatch_close_to_script

Function dispatch_close_to_script 

Source
pub fn dispatch_close_to_script<H: ScriptHost + Resource<Mutability = Mutable>>(
    host: ResMut<'_, H>,
    msgs: ResMut<'_, Messages<CloseRequest>>,
    cursor: Local<'_, MessageCursor<CloseRequest>>,
    out: MessageWriter<'_, ScriptCommandEvent>,
)
Expand description

Forward the window backend’s lumen_core::input::CloseRequest to the script’s on_close() lifecycle hook - before the backend tears anything down, so scripts get a last chance to persist state.

Close veto: an on_close that returns false keeps the window open (a fresh CloseRequest { vetoed: true } is written for the backend’s post-tick veto check). Any other return value, or no on_close function at all, lets the close proceed.

Public so embedders can order their ScriptCommandEvent consumers .after this dispatcher: on a committed close the veto tick is the app’s last tick, so commands on_close emits must be applied in the same tick or they are silently dropped at exit.