pub struct Window<T = Value<String>> { /* private fields */ }Expand description
A window the app opens while it runs: shown while open is true, with
its content built when it opens and disposed when it closes. Declare it
anywhere in the tree, next to the state that opens it; it closes with
the scope that declared it, and belongs to the window it’s declared in.
The close button asks: bind closes it by setting the
flag, or on_close_request lets the app
decide (to ask about unsaved changes, say). Without either, the close
button does nothing.
let editing = signal(false);
Column::new().children((
Button::new("Edit…").on_click(move || editing.set(true)),
Window::new("Machine").bind(editing).content(|| machine_form()),
))In view!, its title is an attribute and its children are its content:
<Window title="Machine" bind=editing>…</Window>.
Implementations§
Source§impl<T> Window<T>
impl<T> Window<T>
Sourcepub fn size(self, size: impl IntoValue<WindowSize>) -> Window<T>
pub fn size(self, size: impl IntoValue<WindowSize>) -> Window<T>
Its content size when it opens: a Size,
WindowSize::FitHeight to fit the height to the content, or
WindowSize::FollowHeight to follow it as it changes. Read each
time it opens, as its modality is, so a change applies at the next
opening.
Sourcepub fn modal(self, modality: Modality) -> Window<T>
pub fn modal(self, modality: Modality) -> Window<T>
Modal: while it’s open, it blocks the window it’s declared in
(Modality::Window, a sheet on macOS) or the whole app
(Modality::Application), and stays above that window. Set
before it opens. Like any dialog, Escape asks it to close, as its
close button does (on AppKit a ButtonRole::Cancel button takes
Escape first). A sheet has no close button: give its content a
way out, e.g. that Cancel button.
Sourcepub fn modality(self, modality: impl IntoValue<Option<Modality>>) -> Window<T>
pub fn modality(self, modality: impl IntoValue<Option<Modality>>) -> Window<T>
Modal or not, as a value that can change: read each time it opens, so a change applies at the next opening.
Sourcepub fn bind(self, open: Signal<bool>) -> Window<T>
pub fn bind(self, open: Signal<bool>) -> Window<T>
Shown while the signal is true; the close button sets it false.
Sourcepub fn full_screen(self, full_screen: Signal<bool>) -> Window<T>
pub fn full_screen(self, full_screen: Signal<bool>) -> Window<T>
In full screen while full_screen is true, the platform’s own way:
a Space of its own on macOS, the whole screen elsewhere, with the
platform’s own way out. The user can change it too (the title bar’s
button on macOS, the window manager’s key), which sets the signal.
Sourcepub fn maximized(self, maximized: Signal<bool>) -> Window<T>
pub fn maximized(self, maximized: Signal<bool>) -> Window<T>
Maximized while maximized is true, as the platform maximizes a
window: its screen’s working area (on macOS, zoomed to fit it). The
user can change it too (the title bar’s button, a double-click on
it, the window manager’s key), which sets the signal.
Sourcepub fn frame(self, frame: Signal<Option<WindowFrame>>) -> Window<T>
pub fn frame(self, frame: Signal<Option<WindowFrame>>) -> Window<T>
Its restored frame (see WindowFrame): where it is and how large
when it’s neither maximized nor in full screen. A Some when it
opens places and sizes it there, in place of its size and
placement (moved onto a screen if it’s on none any more, and no
larger than that screen); setting it while it’s open moves and
resizes it. The platform fills it in as the window shows and keeps
it as the user moves and resizes it, so an app saves it when the
window closes and hands it back the next time to open it as it was
left. Maximizing it doesn’t change it.
Sourcepub fn placement(self, placement: impl IntoValue<Placement>) -> Window<T>
pub fn placement(self, placement: impl IntoValue<Placement>) -> Window<T>
Where it opens when its frame doesn’t say: where the platform
puts a new window (the default), or centred on its screen. Read each
time it opens. To centre it while it’s open, Ui::centre_window.
Sourcepub fn resizable(self, resizable: impl IntoValue<bool>) -> Window<T>
pub fn resizable(self, resizable: impl IntoValue<bool>) -> Window<T>
Whether the user can resize it; they can unless it’s set false. The app can still size it, and a window that follows its content’s height still does.
Sourcepub fn min_size(self, size: impl IntoValue<Size>) -> Window<T>
pub fn min_size(self, size: impl IntoValue<Size>) -> Window<T>
The smallest content size the user can make it. Smaller when it’s set, it grows to it.
Sourcepub fn on_open(self, handler: impl Fn() + 'static) -> Window<T>
pub fn on_open(self, handler: impl Fn() + 'static) -> Window<T>
Called each time it opens, before its content is built: to start a form from what’s saved, say.
Sourcepub fn on_close_request(self, handler: impl Fn() + 'static) -> Window<T>
pub fn on_close_request(self, handler: impl Fn() + 'static) -> Window<T>
Called when the user asks to close it (the close button, ⌘W, Alt+F4). It stays open unless the app closes it.
Sourcepub fn on_active_changed(self, handler: impl Fn(bool) + 'static) -> Window<T>
pub fn on_active_changed(self, handler: impl Fn(bool) + 'static) -> Window<T>
Called when it becomes the active window, the one taking keys, or stops being it.
Sourcepub fn node_ref(self, node: NodeRef) -> Window<T>
pub fn node_ref(self, node: NodeRef) -> Window<T>
Points node at the window while it’s open, to bring it forward
from code (NodeRef::present): open.set(true) alone does
nothing to a window that’s open behind other apps’ windows.