[−][src]Struct winit_input_helper::WinitInputHelper
The main struct of the API.
Create with WinitInputHelper::new
.
Call update
for every winit::event::Event
you receive from winit.
Run your application logic when update
returns true, callng any of the accessor methods you need.
Methods
impl WinitInputHelper
[src]
pub fn new() -> WinitInputHelper
[src]
pub fn update<T>(&mut self, event: Event<T>) -> bool
[src]
Pass every winit event to this function and run your application logic when it returns true.
The following winit events are handled:
Event::NewEvents
clears all internal state.Event::MainEventsCleared
causes this function to return true.Event::WindowEvent
updates internal state, this will affect the result of accessor methods immediately.
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<PhysicalSize<u32>>
[src]
Returns the current window size if it was resized between the last two update*()
calls.
Otherwise returns None
pub fn scale_factor_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.
Trait Implementations
impl Clone for WinitInputHelper
[src]
fn clone(&self) -> WinitInputHelper
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl RefUnwindSafe for WinitInputHelper
impl Send for WinitInputHelper
impl Sync for WinitInputHelper
impl Unpin for WinitInputHelper
impl UnwindSafe for WinitInputHelper
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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>,