pub struct EventPump { /* private fields */ }
Expand description
A thread-safe type that encapsulates SDL event-pumping functions.
Implementations
sourceimpl EventPump
impl EventPump
sourcepub fn is_event_enabled(&self, event_type: EventType) -> bool
pub fn is_event_enabled(&self, event_type: EventType) -> bool
Query if an event type is enabled.
sourcepub fn enable_event(&mut self, event_type: EventType) -> bool
pub fn enable_event(&mut self, event_type: EventType) -> bool
Enable an event type. Returns if the event type was enabled before the call.
sourcepub fn disable_event(&mut self, event_type: EventType) -> bool
pub fn disable_event(&mut self, event_type: EventType) -> bool
Disable an event type. Returns if the event type was enabled before the call.
sourcepub fn poll_event(&mut self) -> Option<Event>
pub fn poll_event(&mut self) -> Option<Event>
Polls for currently pending events.
If no events are pending, None
is returned.
sourcepub fn poll_iter(&mut self) -> EventPollIterator<'_>ⓘNotable traits for EventPollIterator<'a>impl<'a> Iterator for EventPollIterator<'a> type Item = Event;
pub fn poll_iter(&mut self) -> EventPollIterator<'_>ⓘNotable traits for EventPollIterator<'a>impl<'a> Iterator for EventPollIterator<'a> type Item = Event;
Returns a polling iterator that calls poll_event()
.
The iterator will terminate once there are no more pending events.
Example
let sdl_context = sdl2::init().unwrap();
let mut event_pump = sdl_context.event_pump().unwrap();
for event in event_pump.poll_iter() {
use sdl2::event::Event;
match event {
Event::KeyDown {..} => { /*...*/ }
_ => ()
}
}
sourcepub fn pump_events(&mut self)
pub fn pump_events(&mut self)
Pumps the event loop, gathering events from the input devices.
sourcepub fn wait_event(&mut self) -> Event
pub fn wait_event(&mut self) -> Event
Waits indefinitely for the next available event.
sourcepub fn wait_event_timeout(&mut self, timeout: u32) -> Option<Event>
pub fn wait_event_timeout(&mut self, timeout: u32) -> Option<Event>
Waits until the specified timeout (in milliseconds) for the next available event.
sourcepub fn wait_iter(&mut self) -> EventWaitIterator<'_>ⓘNotable traits for EventWaitIterator<'a>impl<'a> Iterator for EventWaitIterator<'a> type Item = Event;
pub fn wait_iter(&mut self) -> EventWaitIterator<'_>ⓘNotable traits for EventWaitIterator<'a>impl<'a> Iterator for EventWaitIterator<'a> type Item = Event;
Returns a waiting iterator that calls wait_event()
.
Note: The iterator will never terminate.
sourcepub fn wait_timeout_iter(
&mut self,
timeout: u32
) -> EventWaitTimeoutIterator<'_>ⓘNotable traits for EventWaitTimeoutIterator<'a>impl<'a> Iterator for EventWaitTimeoutIterator<'a> type Item = Event;
pub fn wait_timeout_iter(
&mut self,
timeout: u32
) -> EventWaitTimeoutIterator<'_>ⓘNotable traits for EventWaitTimeoutIterator<'a>impl<'a> Iterator for EventWaitTimeoutIterator<'a> type Item = Event;
Returns a waiting iterator that calls wait_event_timeout()
.
Note: The iterator will never terminate, unless waiting for an event exceeds the specified timeout.
pub fn keyboard_state(&self) -> KeyboardState<'_>
pub fn mouse_state(&self) -> MouseState
pub fn relative_mouse_state(&self) -> RelativeMouseState
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for EventPump
impl !Send for EventPump
impl !Sync for EventPump
impl Unpin for EventPump
impl UnwindSafe for EventPump
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more