Trait kas::Widget [−][src]
pub trait Widget: SendEvent { }
Expand description
Widget trait
Widgets must implement a family of traits, of which this trait is the final member:
WidgetCore
— base functionality (this trait is always derived)WidgetChildren
— enumerates children and provides methods derived from thisLayout
— handles sizing and positioning of self and childrenWidgetConfig
— the last unparametrised trait allows customisation of some aspects of widget behaviourevent::Handler
— parametrised widgets over aMsg
type and handles eventsevent::SendEvent
— routes events to children and handles responsesWidget
— the final trait
Widgets must use the derive(Widget)
macro to implement at least
WidgetCore
and Widget
; these two traits must not be implemented
manually or users may face unexpected breaking changes.
This macro can optionally implement all above traits, and by default will
implement all except for Layout
. This opt-out derive behaviour means
that adding additional traits into the family is not a breaking change.
To refer to a widget via dyn trait, use &dyn WidgetConfig
(or, if the
message type is known, one may use &dyn Widget<Msg = M>
).
To refer to a widget in generic functions, use <W: Widget>
or
<M, W: Widget<Msg = M>>
.