pub trait ComponentHandle {
    fn as_weak(&self) -> Weak<Self>
    where
        Self: Sized
; fn clone_strong(&self) -> Self; fn show(&self); fn hide(&self); fn window(&self) -> &Window; fn run(&self); fn global<'a, T>(&'a self) -> T
    where
        T: Global<'a, Self>,
        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§

fn as_weak(&self) -> Weak<Self>where
    Self: Sized,

Returns a new weak pointer.

fn clone_strong(&self) -> Self

Returns a clone of this handle that’s a strong reference.

fn show(&self)

Marks the window of this component to be shown on the screen. This registers the window with the windowing system. In order 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.

fn hide(&self)

Marks the window of this component to be hidden on the screen. This de-registers the window from the windowing system and it will not receive any further events.

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.

fn run(&self)

This is a convenience function that first calls Self::show, followed by crate::run_event_loop() and Self::hide.

fn global<'a, T>(&'a self) -> Twhere
    T: Global<'a, Self>,
    Self: Sized,

This function provides access to instances of global singletons exported in .slint. See Global for an example how to export and access globals from .slint markup.

Implementors§