pub fn focused_environment<T>() -> Option<T>where
T: Clone + 'static,Expand description
The ambient T of the window that currently has focus (docs/state.md): SwiftUI’s
@FocusedValue.
environment answers “what did my ancestors provide”, which is the right question inside a
piece and the wrong one inside an app-wide menu action: a desktop menu bar is one bar for the
whole app, and its commands act on the front window. This resolves through that window’s own
scope instead of the calling scope, so File ▸ New Item adds to the list the user is
looking at. A cover that provides no T answers with the primary window’s, since the
cover renders inside it (following the window scope chain). None ⇒ no window is
open, or the front one provides no T.