Expand description
Window service, widget, events, commands and other types.
The Window!
widget instantiates a window root, the windows service uses the window root as the
root widget of new window.
The example below declares a window that toggles if it can close.
use zng::prelude::*;
fn app() {
APP.defaults().run_window(async { window() });
}
fn window() -> window::WindowRoot {
let allow_close = var(true);
Window! {
on_close_requested = hn!(allow_close, |args: &window::WindowCloseRequestedArgs| {
if !allow_close.get() {
args.propagation().stop();
}
});
title = "Can I Close?";
child_align = layout::Align::CENTER;
child = Toggle! {
child = Text!(allow_close.map(|a| formatx!("allow close = {a:?}")));
checked = allow_close;
}
}
}
The WINDOWS
service can be used to open, manage and close windows. The example below
opens a parent and child window.
use zng::prelude::*;
fn app() {
APP.defaults().run(async {
let r = WINDOWS.open(async { main_window() });
println!("opened {}", r.wait_rsp().await);
});
}
fn main_window() -> window::WindowRoot {
Window! {
title = "Main Window";
child_align = layout::Align::CENTER;
child = {
let enabled = var(true);
Button! {
child = Text!("Open/Close Child");
on_click = async_hn!(enabled, |_| {
enabled.set(false);
if WINDOWS.is_open("child-id") {
if let Ok(r) = WINDOWS.close("child-id") {
r.wait_done().await;
}
} else {
let parent = WINDOW.id();
WINDOWS.open_id(
"child-id",
async move { child_window(parent) }
)
.wait_done()
.await;
}
enabled.set(true);
});
widget::enabled;
}
}
}
}
fn child_window(parent: WindowId) -> window::WindowRoot {
Window! {
parent;
title = "Child Window";
size = (200, 100);
child = Button! {
child = Text!("Close");
on_click = hn!(|_| {
let _ = WINDOW.close();
});
};
}
}
§Full API
See zng_ext_window
, zng_app::window
and zng_wgt_window
for the full window API.
Modules§
- Window commands.
- Debug inspection helpers.
Structs§
- Window auto-size config.
FRAME_IMAGE_READY_EVENT
args.- “Monitor” configuration used by windows in headless mode.
- Arguments for
IME_EVENT
. - Monitors service.
- Unique identifier of a monitor screen.
- All information about a monitor that
MONITORS
can provide. MONITORS_CHANGED_EVENT
args.- Defines what window operations can run in parallel, between windows.
- Exclusive video mode info.
- Current context window.
- Windows service.
W
A window container.- Window chrome buttons.
WINDOW_CHANGED_EVENT
args.WINDOW_CLOSE_EVENT
args.- Unique identifier of an open window.
- Represents a handle that stops the window from loading while the handle is alive.
WINDOW_OPEN_EVENT
args.- Window root node and values.
- Arguments for
WINDOWS.register_root_extender
. - Mask of allowed
WindowState
states of a window. - Variables that configure the opening or open window.
Enums§
- Defines if a widget load affects the parent window load.
- Response message of
close
andclose_together
. - Represents a focus request indicator.
- Frame image capture mode in a window.
- A selector that returns a
MonitorInfo
. - Render backend preference.
- Window startup position.
- Window icon.
- Mode of an open window.
- Window state.
Statics§
- A window frame has finished rendering.
- Input Method Editor event targeting a text input widget.
- Monitors added, removed or modified event.
- Window moved, resized or other state changed.
- Window closed event.
- Window close requested event.
- Window finished loading and has opened in the view-process.
- New window has inited.
Traits§
- Extension trait, adds
run_window
toAppExtended
. - Window extension methods for
HeadlessApp
. - IME extension methods for
WidgetInfoBuilder
. - IME extension methods for
WidgetInfo
.
Functions§
- Default handler registered in mobile platforms.
P
On window frame rendered.P
On Input Method Editor event.P
Previewon_frame_image_ready
event.P
Previewon_ime
event.P
Previewon_window_changed
event.P
Previewon_window_close_requested
event.P
Previewon_window_exited_fullscreen
event.P
Previewon_window_fullscreen
event.P
Previewon_window_load
event.P
Previewon_window_maximized
event.P
Previewon_window_minimized
event.P
Previewon_window_moved
event.P
Previewon_window_open
event.P
Previewon_window_resized
event.P
Previewon_window_restored
event.P
Previewon_window_state_changed
event.P
Previewon_window_unmaximized
event.P
Previewon_window_unminimized
event.P
On window moved, resized or other state changed.P
On window close requested.P
On window state changed fromWindowState::is_fullscreen
.P
On window state changed toWindowState::is_fullscreen
.P
On window loaded.P
On window state changed toWindowState::Maximized
.P
On window state changed toWindowState::Minimized
.P
On window position changed.P
On window opened.P
On window size changed.P
On window state changed toWindowState::Normal
.P
On window state changed.P
On window state changed fromWindowState::Maximized
.P
On window state changed fromWindowState::Minimized
.