pub struct Touchpad<Id, Coord>where
Id: PartialEq,
Coord: Copy + Default + Add<Output = Coord>,{ /* private fields */ }
Expand description
A structure representing the current state of touches on a touch device.
Implementations§
source§impl<Id, Coord> Touchpad<Id, Coord>where
Id: PartialEq,
Coord: Copy + Default + Add<Output = Coord>,
impl<Id, Coord> Touchpad<Id, Coord>where Id: PartialEq, Coord: Copy + Default + Add<Output = Coord>,
pub fn new() -> Self
sourcepub fn first_touch(&self) -> Option<&Touch<Id, Coord>>
pub fn first_touch(&self) -> Option<&Touch<Id, Coord>>
Returns a reference to the first registered touch, if any.
sourcepub fn touch<I: AsRef<Id>>(&self, id: I) -> Option<&Touch<Id, Coord>>
pub fn touch<I: AsRef<Id>>(&self, id: I) -> Option<&Touch<Id, Coord>>
Returns a touch by its id
, if it exists.
sourcepub fn touches(&self) -> impl Iterator<Item = &Touch<Id, Coord>>
pub fn touches(&self) -> impl Iterator<Item = &Touch<Id, Coord>>
Returns an iterator over all active touches.
(This includes touches that have been released this frame.)
sourcepub fn touch_event<I, P>(
&mut self,
id: I,
position: [Coord; 2],
phase: P
) -> &mut Selfwhere
I: Into<Id>,
P: Into<TouchPhase>,
pub fn touch_event<I, P>( &mut self, id: I, position: [Coord; 2], phase: P ) -> &mut Selfwhere I: Into<Id>, P: Into<TouchPhase>,
Register a touch event.
sourcepub fn clear_taps(&mut self) -> &mut Self
pub fn clear_taps(&mut self) -> &mut Self
Clears the tapped/released state of active touches. Should be called at the end of each frame.
sourcepub fn handle_event<E: Event<Self>>(&mut self, event: &E) -> &mut Self
pub fn handle_event<E: Event<Self>>(&mut self, event: &E) -> &mut Self
Convenience method for handling events. The type of event, E
, will
vary depending on the windowing library being used.
Trait Implementations§
source§impl<Id, Coord> Clone for Touchpad<Id, Coord>where
Id: PartialEq + Clone,
Coord: Copy + Default + Add<Output = Coord> + Clone,
impl<Id, Coord> Clone for Touchpad<Id, Coord>where Id: PartialEq + Clone, Coord: Copy + Default + Add<Output = Coord> + Clone,
source§impl<Id, Coord> Debug for Touchpad<Id, Coord>where
Id: PartialEq + Debug,
Coord: Copy + Default + Add<Output = Coord> + Debug,
impl<Id, Coord> Debug for Touchpad<Id, Coord>where Id: PartialEq + Debug, Coord: Copy + Default + Add<Output = Coord> + Debug,
Auto Trait Implementations§
impl<Id, Coord> RefUnwindSafe for Touchpad<Id, Coord>where Coord: RefUnwindSafe, Id: RefUnwindSafe,
impl<Id, Coord> Send for Touchpad<Id, Coord>where Coord: Send, Id: Send,
impl<Id, Coord> Sync for Touchpad<Id, Coord>where Coord: Sync, Id: Sync,
impl<Id, Coord> Unpin for Touchpad<Id, Coord>where Coord: Unpin, Id: Unpin,
impl<Id, Coord> UnwindSafe for Touchpad<Id, Coord>where Coord: UnwindSafe, Id: UnwindSafe,
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