Skip to main content

run_with

Function run_with 

Source
pub fn run_with<F>(path: &str, on_action: F)
where F: FnMut(&mut StandaloneHandle<'_>, PaneAction) + 'static,
Expand description

Like run, but gives you a StandaloneHandle each frame to call write, toast, etc.

on_action is called once per PaneAction emitted that frame.

pane::run_with("assets/menu.ron", |ui, action| {
    if let pane::PaneAction::Custom(ref id) = action {
        if id == "save" { ui.push_toast("Saved!", 2.0, 0.0, -400.0, 300.0, 60.0); }
    }
});

ยงPanics

Panics if the .ron file cannot be read or parsed, or if the standalone wgpu device/queue are not yet initialized when the first frame fires.