diff --git a/crates/kas-core/src/event/cx/config.rs b/crates/kas-core/src/event/cx/config.rs index a172bc4b..222946bb 100644 --- a/crates/kas-core/src/event/cx/config.rs +++ b/crates/kas-core/src/event/cx/config.rs @@ -9,12 +9,10 @@ use super::PendingNavFocus; use crate::event::{EventState, FocusSource}; use crate::geom::{Rect, Size}; use crate::layout::AlignPair; -use crate::messages::Erased; use crate::text::format::FormattableText; use crate::theme::{Feature, SizeCx, Text, ThemeSize}; use crate::{Id, Node}; use cast::Cast; -use std::fmt::Debug; use std::ops::{Deref, DerefMut}; #[allow(unused)] use crate::event::{Event, EventCx}; @@ -92,13 +90,12 @@ impl<'a> ConfigCx<'a> { widget._update(self); } + /* TODO: can we support these (i.e. track `id`)? /// Push a message (replay) /// /// Unlike [`EventCx::push`], this is not handled while unwinding /// from event sending, but via a fresh traversal of the widget tree. - /// - /// TODO: `id` should not be part of the function signature? - pub fn push(&mut self, id: Id, msg: M) { + pub fn push(&mut self, msg: M) { self.send(id, msg); } @@ -110,9 +107,10 @@ impl<'a> ConfigCx<'a> { /// The message may be [popped](EventCx::try_pop) or /// [observed](EventCx::try_observe) from [`Events::handle_messages`] /// by the widget itself, its parent, or any ancestor. - pub fn push_erased(&mut self, id: Id, msg: Erased) { + pub fn push_erased(&mut self, msg: Erased) { self.send_erased(id, msg); } + */ /// Align a feature's rect /// diff --git a/crates/kas-core/src/event/cx/cx_pub.rs b/crates/kas-core/src/event/cx/cx_pub.rs index 36af21e7..5a355748 100644 --- a/crates/kas-core/src/event/cx/cx_pub.rs +++ b/crates/kas-core/src/event/cx/cx_pub.rs @@ -596,11 +596,19 @@ impl EventState { } /// Send a message to `id` + /// + /// Similar to [`EventCx::push`], the message is sent as part of a widget + /// tree traversal. + /// The message may be [popped](EventCx::try_pop) or + /// [observed](EventCx::try_observe) from [`Events::handle_messages`] + /// by the widget itself, its parent, or any ancestor. pub fn send(&mut self, id: Id, msg: M) { self.send_erased(id, Erased::new(msg)); } - /// Send an erased message to `id` + /// Push a type-erased message to the stack + /// + /// This is a lower-level variant of [`Self::send`]. pub fn send_erased(&mut self, id: Id, msg: Erased) { self.send_queue.push_back((id, msg)); } diff --git a/examples/gallery.rs b/examples/gallery.rs index 86565134..17a42eec 100644 --- a/examples/gallery.rs +++ b/examples/gallery.rs @@ -331,7 +331,7 @@ Demonstration of *as-you-type* formatting from **Markdown**. .with_text(DOC), ScrollLabel::new(Markdown::new(DOC).unwrap()) .on_configure(|cx, label| { - cx.push(label.id(), SetLabelId(label.id())); + cx.send(label.id(), SetLabelId(label.id())); }) .on_message(|cx, label, text| { let act = label.set_text(text);