Skip to main content

NativeRender

Trait NativeRender 

Source
pub trait NativeRender: CustomWidget {
    type View: Message + DowncastTarget + AsRef<NSView>;

    // Required methods
    fn create(
        props: &Self::Props,
        cx: &mut AppKitCx<'_>,
    ) -> Retained<Self::View> ⓘ;
    fn update(view: &Self::View, old: &Self::Props, new: &Self::Props);

    // Provided methods
    fn measure(
        view: &Self::View,
        props: &Self::Props,
        request: &MeasureRequest,
    ) -> Option<Size> { ... }
    fn read(view: &Self::View, props: &Self::Props) -> Self::Props { ... }
    fn perform(
        view: &Self::View,
        props: &Self::Props,
        action: &A11yAction,
        emitter: &Emitter,
    ) -> Result<(), ActionError> { ... }
}
Expand description

A custom widget’s AppKit render: one per widget, next to its shared definition (e.g. rating/macos.rs). Hand it to the widget’s Render impl with native.

Custom widgets are controlled: when the user changes the view, emit an event; the app answers with new props, and update shows them.

Required Associated Types§

Required Methods§

Source

fn create(props: &Self::Props, cx: &mut AppKitCx<'_>) -> Retained<Self::View> ⓘ

Source

fn update(view: &Self::View, old: &Self::Props, new: &Self::Props)

Provided Methods§

Source

fn measure( view: &Self::View, props: &Self::Props, request: &MeasureRequest, ) -> Option<Size>

Intrinsic size. None uses the view’s intrinsicContentSize.

Source

fn read(view: &Self::View, props: &Self::Props) -> Self::Props

Props as the view shows them, so tests can catch a view that doesn’t show what it was given. The default trusts the last props.

Source

fn perform( view: &Self::View, props: &Self::Props, action: &A11yAction, emitter: &Emitter, ) -> Result<(), ActionError>

Carries out an accessibility action on the view. The default, Unsupported, lets the shared CustomWidget::action decide.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§