Struct titanium::desktop::gui::libdruid::Notification
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. Commands are delivered from the
root of the tree down towards the target, and this delivery occurs after
the originating event call has returned. Notifications 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§
§impl Notification
impl Notification
pub fn source(&self) -> WidgetId
pub fn source(&self) -> WidgetId
The WidgetId of the Widget that sent this Notification.
pub fn warn_if_unused(self, warn_if_unused: bool) -> Notification
pub fn warn_if_unused(self, warn_if_unused: bool) -> Notification
Builder-style method to set warn_if_unused.
The default is true.
pub 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.
pub 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§
§impl Clone for Notification
impl Clone for Notification
§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