pub trait WidgetExt<T: Data>: Widget<T> + Sized + 'static {
    // Provided methods
    fn on_command<CT: 'static>(
        self,
        selector: Selector<CT>,
        handler: impl Fn(&mut EventCtx<'_, '_>, &CT, &mut T) + 'static
    ) -> ControllerHost<Self, OnCmd<CT, T>> { ... }
    fn on_notify<CT: 'static>(
        self,
        selector: Selector<CT>,
        handler: impl Fn(&mut EventCtx<'_, '_>, &CT, &mut T) + 'static
    ) -> OnNotify<CT, T> { ... }
    fn on_change(
        self,
        f: impl Fn(&mut EventCtx<'_, '_>, &T, &mut T, &Env) + 'static
    ) -> ControllerHost<Self, OnChange<T>> { ... }
    fn show_if(self, f: ShowIfCallback<T>) -> ShowIf<T> { ... }
}
Expand description

一些常用的组件扩展特质

Provided Methods§

source

fn on_command<CT: 'static>( self, selector: Selector<CT>, handler: impl Fn(&mut EventCtx<'_, '_>, &CT, &mut T) + 'static ) -> ControllerHost<Self, OnCmd<CT, T>>

用当该组件接收到指定的 [druid::Command] 时产生回调的控制器 crate::widgets::OnCmd 包裹当前组件

source

fn on_notify<CT: 'static>( self, selector: Selector<CT>, handler: impl Fn(&mut EventCtx<'_, '_>, &CT, &mut T) + 'static ) -> OnNotify<CT, T>

用当该组件接收到指定的 [druid::Notification] 时产生回调的控制器 crate::widgets::OnNotify 包裹当前组件

source

fn on_change( self, f: impl Fn(&mut EventCtx<'_, '_>, &T, &mut T, &Env) + 'static ) -> ControllerHost<Self, OnChange<T>>

Calls the function when data changes in a child widget

&T is the old data and &mut T is the new data

source

fn show_if(self, f: ShowIfCallback<T>) -> ShowIf<T>

当数据变更时触发回调,如果为 true 则显示包裹起来的组件,否则隐藏

且隐藏时不会占用布局体积

Implementors§

source§

impl<T: Data, W: Widget<T> + 'static> WidgetExt<T> for W