pub struct CustomEvent {
pub source: Option<WidgetId>,
pub target: EventTarget,
pub payload: Rc<dyn Any>,
}Expand description
An application- or library-defined event, carried by Event::Custom.
The payload is any 'static value; receivers read it back with CustomEvent::payload, which
returns None for any other type. Pushrod never looks inside a custom event, and it has no
side effects on focus, mouse capture, selection, or redrawing.
§Examples
use pushrod::event::{CustomEvent, EventTarget};
use std::rc::Rc;
struct Saved(u32);
let event = CustomEvent {
source: None,
target: EventTarget::Broadcast,
payload: Rc::new(Saved(3)),
};
assert_eq!(event.payload::<Saved>().unwrap().0, 3);
assert!(event.payload::<String>().is_none());Fields§
§source: Option<WidgetId>The Widget that posted the event, or None if the application or another thread did.
target: EventTargetWhich Widgets receive the event.
payload: Rc<dyn Any>The application’s data.
Implementations§
Trait Implementations§
Source§impl Clone for CustomEvent
impl Clone for CustomEvent
Auto Trait Implementations§
impl !RefUnwindSafe for CustomEvent
impl !Send for CustomEvent
impl !Sync for CustomEvent
impl !UnwindSafe for CustomEvent
impl Freeze for CustomEvent
impl Unpin for CustomEvent
impl UnsafeUnpin for CustomEvent
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
Mutably borrows from an owned value. Read more