Available on crate feature
unstable-winit-030
only.Expand description
Winit 0.30.x specific types and re-exports.
Note: This module is behind a feature flag and may be removed or changed in future minor releases, as new major Winit releases become available.
Use the types and traits in this module in combination with other APIs to access additional window properties, create custom windows, or hook into the winit event loop.
For example, use the WinitWindowAccessor
to obtain access to the underling [winit::window::Window
]:
Cargo.toml
:
slint = { version = "~1.12", features = ["unstable-winit-030"] }
main.rs
:
// Bring winit and accessor traits into scope.
use slint::winit_030::{WinitWindowAccessor, winit};
slint::slint!{
import { VerticalBox, Button } from "std-widgets.slint";
export component HelloWorld inherits Window {
callback clicked;
VerticalBox {
Text {
text: "hello world";
color: green;
}
Button {
text: "Click me";
clicked => { root.clicked(); }
}
}
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Make sure the winit backed is selected:
slint::BackendSelector::new()
.backend_name("winit".into())
.select()?;
let app = HelloWorld::new()?;
let app_weak = app.as_weak();
app.on_clicked(move || {
// access the winit window
let app = app_weak.unwrap();
app.window().with_winit_window(|winit_window: &winit::window::Window| {
eprintln!("window id = {:#?}", winit_window.id());
});
});
app.run()?;
Ok(())
}
See also BackendSelector::with_winit_030_event_loop_builder()
and BackendSelector::with_winit_030_window_attributes_hook()
.
Re-exports§
pub use i_slint_backend_winit::winit;
Structs§
- Slint
Event - Internal type used by the winit backend for thread communication and window system updates.
Enums§
- Winit
Window Event Result - Returned by callbacks passed to
Window::on_winit_window_event
to determine if winit events should propagate to the Slint event loop.
Traits§
- Winit
Window Accessor - This helper trait can be used to obtain access to the [
winit::window::Window
] for a givenslint::Window
.
Type Aliases§
- Event
Loop Builder - Convenience alias for the event loop builder used by Slint.