pub trait ComponentHandle {
// Required methods
fn as_weak(&self) -> Weak<Self>
where Self: Sized;
fn clone_strong(&self) -> Self;
fn show(&self) -> Result<(), PlatformError>;
fn hide(&self) -> Result<(), PlatformError>;
fn window(&self) -> &Window;
fn run(&self) -> Result<(), PlatformError>;
fn global<'a, T: Global<'a, Self>>(&'a self) -> T
where Self: Sized;
}
Expand description
This trait describes the common public API of a strongly referenced Slint component. It allows creating strongly-referenced clones, a conversion into/ a weak pointer as well as other convenience functions.
This trait is implemented by the generated component
Required Methods§
Sourcefn clone_strong(&self) -> Self
fn clone_strong(&self) -> Self
Returns a clone of this handle that’s a strong reference.
Sourcefn show(&self) -> Result<(), PlatformError>
fn show(&self) -> Result<(), PlatformError>
Convenience function for crate::Window::show()
.
This shows the window on the screen and maintains an extra strong reference while
the window is visible. To react to events from the windowing system, such as draw
requests or mouse/touch input, it is still necessary to spin the event loop,
using crate::run_event_loop
.
Sourcefn hide(&self) -> Result<(), PlatformError>
fn hide(&self) -> Result<(), PlatformError>
Convenience function for crate::Window::hide()
.
Hides the window, so that it is not visible anymore. The additional strong reference
on the associated component, that was created when show() was called, is dropped.
Sourcefn window(&self) -> &Window
fn window(&self) -> &Window
Returns the Window associated with this component. The window API can be used to control different aspects of the integration into the windowing system, such as the position on the screen.
Sourcefn run(&self) -> Result<(), PlatformError>
fn run(&self) -> Result<(), PlatformError>
This is a convenience function that first calls Self::show
, followed by crate::run_event_loop()
and Self::hide
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.