Struct druid::Notification
source · pub struct Notification { /* private fields */ }
Expand description
A message passed up the tree from a Widget
to its ancestors.
In the course of handling an event, a Widget
may change some internal
state that is of interest to one of its ancestors. In this case, the widget
may submit a Notification
.
In practice, a Notification
is very similar to a Command
; the
main distinction relates to delivery. Command
s are delivered from the
root of the tree down towards the target, and this delivery occurs after
the originating event call has returned. Notification
s are delivered up
the tree, and this occurs during event handling; immediately after the
child widget’s event
method returns, the notification will be delivered
to the child’s parent, and then the parent’s parent, until the notification
is handled.
Implementations§
source§impl Notification
impl Notification
sourcepub fn warn_if_unused(self, warn_if_unused: bool) -> Self
pub fn warn_if_unused(self, warn_if_unused: bool) -> Self
Builder-style method to set warn_if_unused
.
The default is true
.
sourcepub fn warn_if_unused_set(&self) -> bool
pub fn warn_if_unused_set(&self) -> bool
Returns whether there should be a warning when no widget handles this notification.
sourcepub fn route(&self) -> WidgetId
pub fn route(&self) -> WidgetId
The WidgetId
of the last Widget
that this Notification
was passed through.
Example
fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut (), env: &Env) {
if let Event::Notification(notification) = event {
if notification.route() == self.widget1.id() {
// the notification came from inside of widget1
}
if notification.route() == self.widget2.id() {
// the notification came from inside of widget2
}
}
}
Trait Implementations§
source§impl Clone for Notification
impl Clone for Notification
source§fn clone(&self) -> Notification
fn clone(&self) -> Notification
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more