pub trait Widgetwhere
Self: Update,
Self::Root: Clone + IsA<Object> + IsA<Widget>,{
type Root;
// Required methods
fn root(&self) -> Self::Root;
fn view(relm: &Relm<Self>, model: Self::Model) -> Self;
// Provided methods
fn init_view(&mut self) { ... }
fn on_add<W: IsA<Widget> + IsA<Object>>(&self, _parent: W) { ... }
fn parent_id() -> Option<&'static str> { ... }
fn run(model_param: Self::ModelParam) -> Result<(), BoolError>
where Self: 'static { ... }
}
Expand description
Trait to implement to manage widget’s events.
Required Associated Types§
Required Methods§
Provided Methods§
sourcefn init_view(&mut self)
fn init_view(&mut self)
Update the view after it is initially created.
This method is only useful when using the #[widget]
attribute, because when not using it,
you can use the view()
method instead.
sourcefn on_add<W: IsA<Widget> + IsA<Object>>(&self, _parent: W)
fn on_add<W: IsA<Widget> + IsA<Object>>(&self, _parent: W)
Method called when the widget is added to its parent. This is currently only used to set the child properties of a widget as relm widget could have child properties and we don’t know its parent when it is defined. Thus, we call on_add() when it is added to its parent to set the child properties.
sourcefn parent_id() -> Option<&'static str>
fn parent_id() -> Option<&'static str>
Get the parent ID.
This is useful for custom Container implementation: when you implement the
Container::add_widget()
, you might want to
insert widgets elsewhere depending of this id.