pub enum EventResult {
Consumed,
ConsumedQuiet,
Ignored,
}Expand description
What a widget returns from crate::widget::Widget::on_event.
§Automatic invalidation
The framework’s event dispatcher (see [crate::widget::tree]) treats a
Consumed result as “this widget changed
something visible” and schedules a repaint via
crate::animation::request_draw on the widget’s behalf. This makes the
correct default automatic: the most common framework bug is a new widget
that mutates paint-affecting state on an event but forgets to request a
draw, so parts of it don’t repaint. With auto-invalidation a plain
Consumed is always safe.
A widget that consumes a high-frequency event (typically MouseMove)
without any visual change — for example, a hover affordance that only
updates the OS cursor — should return
ConsumedQuiet so it doesn’t schedule a
wasteful repaint on every event. ConsumedQuiet still stops propagation
exactly like Consumed; it only suppresses the automatic draw request.
Variants§
Consumed
The widget handled the event and may have changed its appearance; stop propagation and schedule a repaint automatically.
ConsumedQuiet
The widget handled the event (stop propagation) but produced no visual change, so the dispatcher must NOT schedule a repaint. Use this only for genuinely quiet consumption of high-frequency events.
Ignored
The widget did not handle the event; continue bubbling up.
Implementations§
Source§impl EventResult
impl EventResult
Sourcepub const fn is_consumed(self) -> bool
pub const fn is_consumed(self) -> bool
true for both Consumed and
ConsumedQuiet.
Propagation, capture, and focus logic should branch on this rather
than comparing against Consumed directly, so a quietly-consuming
widget still stops the event exactly like a loud one.
Sourcepub const fn requests_redraw(self) -> bool
pub const fn requests_redraw(self) -> bool
true only for Consumed — i.e. the
dispatcher should call crate::animation::request_draw for this
result. ConsumedQuiet and Ignored return false.
Trait Implementations§
Source§impl Clone for EventResult
impl Clone for EventResult
Source§fn clone(&self) -> EventResult
fn clone(&self) -> EventResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for EventResult
Source§impl Debug for EventResult
impl Debug for EventResult
impl Eq for EventResult
Source§impl PartialEq for EventResult
impl PartialEq for EventResult
impl StructuralPartialEq for EventResult
Auto Trait Implementations§
impl Freeze for EventResult
impl RefUnwindSafe for EventResult
impl Send for EventResult
impl Sync for EventResult
impl Unpin for EventResult
impl UnsafeUnpin for EventResult
impl UnwindSafe for EventResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more