[−][src]Struct winit_input_helper::WinitInputHelper
The main struct of the API.
Create with WinitInputHelper::new
.
Then call update
for every winit::event::Event
you receive from winit.
Then run your application logic when update
returns true, callng any of the accessor methods you need.
Methods
impl<T> WinitInputHelper<T>
[src]
pub fn new() -> WinitInputHelper<T>
[src]
pub fn update(&mut self, event: Event<T>) -> bool
[src]
All passed events are queued until an Event::EventsCleared is received.
At this point the WinitInputHelper processes all events and updates its state.
You should run your application logic directly after this occurs.
You can easily tell when this occurs because this method returns
true iff the passed event is an Event::MainEventsCleared
.
pub fn key_pressed(&self, check_key_code: VirtualKeyCode) -> bool
[src]
Returns true when the specified keyboard key goes from "not pressed" to "pressed" Otherwise returns false
pub fn mouse_pressed(&self, check_mouse_button: usize) -> bool
[src]
Returns true when the specified mouse button goes from "not pressed" to "pressed" Otherwise returns false
Left => 0 Right => 1 Middle => 2 Other => 3..255
pub fn key_released(&self, check_key_code: VirtualKeyCode) -> bool
[src]
Returns true when the specified keyboard key goes from "pressed" to "not pressed" Otherwise returns false
pub fn mouse_released(&self, check_mouse_button: usize) -> bool
[src]
Returns true when the specified mouse button goes from "pressed" to "not pressed" Otherwise returns false
Left => 0 Right => 1 Middle => 2 Other => 3..255
pub fn key_held(&self, key_code: VirtualKeyCode) -> bool
[src]
Returns true while the specified keyboard key remains "pressed" Otherwise returns false
pub fn mouse_held(&self, mouse_button: usize) -> bool
[src]
Returns true while the specified mouse button remains "pressed" Otherwise returns false
Left => 0 Right => 1 Middle => 2 Other => 3..255
pub fn held_shift(&self) -> bool
[src]
Returns true while any shift key is held on the keyboard Otherwise returns false
pub fn held_control(&self) -> bool
[src]
Returns true while any control key is held on the keyboard Otherwise returns false
pub fn held_alt(&self) -> bool
[src]
Returns true while any alt key is held on the keyboard Otherwise returns false
pub fn scroll_diff(&self) -> f32
[src]
Returns 0.0
if the mouse is outside of the window.
Otherwise returns the amount scrolled by the mouse in between the last two update*()
calls
pub fn mouse(&self) -> Option<(f32, f32)>
[src]
Returns None
when the mouse is outside of the window.
Otherwise returns the mouse coordinates in pixels
pub fn mouse_diff(&self) -> (f32, f32)
[src]
Returns the difference in mouse coordinates between the last two update*()
calls
Returns (0.0, 0.0)
if the mouse is outside of the window.
pub fn resolution(&self) -> Option<(u32, u32)>
[src]
Returns None
when the mouse is outside of the window.
Otherwise returns the resolution of the window.
pub fn text(&self) -> Vec<TextChar>
[src]
Returns the characters pressed since the last update*()
.
The earlier the character was pressed, the lower the index in the Vec.
pub fn dropped_file(&self) -> Option<PathBuf>
[src]
Returns the path to a file that has been drag-and-dropped onto the window.
pub fn window_resized(&self) -> Option<LogicalSize>
[src]
Returns the current window size if it was resized between the last two update*()
calls.
Otherwise returns None
pub fn hidpi_changed(&self) -> Option<f64>
[src]
Returns the current window size if it was resized between the last two update*()
calls.
Otherwise returns None
pub fn quit(&self) -> bool
[src]
Returns true if the OS has requested the application to quit. Otherwise returns false.
Auto Trait Implementations
impl<T> RefUnwindSafe for WinitInputHelper<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for WinitInputHelper<T> where
T: Send,
T: Send,
impl<T> Sync for WinitInputHelper<T> where
T: Sync,
T: Sync,
impl<T> Unpin for WinitInputHelper<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for WinitInputHelper<T> where
T: UnwindSafe,
T: UnwindSafe,
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>,