[−][src]Struct sdl2::event::EventSender
A sendible type that can push events to the event queue.
Methods
impl EventSender
[src]
pub fn push_event(&self, event: Event) -> Result<(), String>
[src]
Pushes an event to the event queue.
pub fn push_custom_event<T: Any>(&self, event: T) -> Result<(), String>
[src]
Push a custom event
If the event type T
was not registered using
[EventSubsystem::register_custom_event]
(../struct.EventSubsystem.html#method.register_custom_event),
this method will panic.
Example: pushing and receiving a custom event
struct SomeCustomEvent { a: i32 } let sdl = sdl2::init().unwrap(); let ev = sdl.event().unwrap(); let mut ep = sdl.event_pump().unwrap(); ev.register_custom_event::<SomeCustomEvent>().unwrap(); let event = SomeCustomEvent { a: 42 }; ev.push_custom_event(event); let received = ep.poll_event().unwrap(); // or within a for event in ep.poll_iter() if received.is_user_event() { let e2 = received.as_user_event_type::<SomeCustomEvent>().unwrap(); assert_eq!(e2.a, 42); }
Auto Trait Implementations
impl RefUnwindSafe for EventSender
impl Send for EventSender
impl Sync for EventSender
impl Unpin for EventSender
impl UnwindSafe for EventSender
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,