pub fn window<V: IntoView>(
title: &str,
id: &str,
content: impl Fn() -> V,
) -> SceneHandleExpand description
Window(title, id: id) { content } — a single window, not a group.
Unlike a WindowGroup the user cannot open a second one; id is what
openWindow names it by.
Examples found in repository?
examples/scenes.rs (line 295)
282fn main() {
283 // `--describe` asks the same question the event loop would and prints the
284 // answer: what Swift types came out of this. Useful because the types are
285 // the claim — `_TupleScene<(WindowGroup<AnyView>, Settings<AnyView>, …)>` is
286 // what Swift builds from four scenes in a row, and nothing about a window
287 // appearing would say whether that is what got built.
288 #[cfg(target_os = "macos")]
289 if std::env::args().any(|a| a == "--describe") {
290 let whole = body();
291 println!("App.Body\n {}", whole.type_name());
292 for (name, s) in [
293 ("window_group", scene::window_group(main_window)),
294 ("settings", scene::settings(settings_pane)),
295 ("window", scene::window("Utility", "utility", utility_window)),
296 ("menu_bar_extra", scene::menu_bar_extra("Count", "star.fill", menu_bar_item)),
297 ] {
298 println!("{name}\n {}", s.type_name());
299 }
300 // Built through the macro, so this also checks that what `scenes!`
301 // expands to is the same thing the free functions build.
302 let one = scenes! { window_group { text("x") } commands { menu("M") { text("x") } } };
303 println!("scenes! with one menu\n {}", one.type_name());
304 return;
305 }
306
307 // `--probe` launches for real and reports what AppKit built, then quits.
308 #[cfg(target_os = "macos")]
309 if std::env::args().any(|a| a == "--probe") {
310 probe::schedule(2.5);
311 }
312
313 app::run_scene(body)
314}