Struct ndk::event::MotionEvent
source · [−]pub struct MotionEvent { /* private fields */ }
Expand description
A motion event
Wraps an AInputEvent *
of the ffi::AINPUT_EVENT_TYPE_MOTION
type.
For general discussion of motion events in Android, see the relevant javadoc.
Implementations
sourceimpl MotionEvent
impl MotionEvent
sourcepub unsafe fn from_ptr(ptr: NonNull<AInputEvent>) -> Self
pub unsafe fn from_ptr(ptr: NonNull<AInputEvent>) -> Self
Constructs a MotionEvent from a pointer to a native ffi::AInputEvent
Safety
By calling this method, you assert that the pointer is a valid, non-null pointer to a
native ffi::AInputEvent
and that ffi::AInputEvent
is an AMotionEvent
.
sourcepub fn ptr(&self) -> NonNull<AInputEvent>
pub fn ptr(&self) -> NonNull<AInputEvent>
Returns a pointer to the native ffi::AInputEvent
sourcepub fn source(&self) -> Source
pub fn source(&self) -> Source
Get the source of the event.
See the NDK docs
sourcepub fn device_id(&self) -> i32
pub fn device_id(&self) -> i32
Get the device id associated with the event.
See the NDK docs
sourcepub fn action(&self) -> MotionAction
pub fn action(&self) -> MotionAction
Returns the motion action associated with the event.
See the NDK docs
sourcepub fn pointer_index(&self) -> usize
pub fn pointer_index(&self) -> usize
Returns the pointer index of an Up
or Down
event.
Pointer indices can change per motion event. For an identifier that stays the same, see
Pointer::pointer_id()
.
This only has a meaning when the action is one of Up
,
Down
, PointerUp
,
or PointerDown
.
sourcepub fn pointer_count(&self) -> usize
pub fn pointer_count(&self) -> usize
Returns the number of pointers in this event
See the NDK docs
sourcepub fn pointers(&self) -> PointersIter<'_>ⓘNotable traits for PointersIter<'a>impl<'a> Iterator for PointersIter<'a> type Item = Pointer<'a>;
pub fn pointers(&self) -> PointersIter<'_>ⓘNotable traits for PointersIter<'a>impl<'a> Iterator for PointersIter<'a> type Item = Pointer<'a>;
An iterator over the pointers in this motion event
sourcepub fn pointer_at_index(&self, index: usize) -> Pointer<'_>
pub fn pointer_at_index(&self, index: usize) -> Pointer<'_>
The pointer at a given pointer index. Panics if the pointer index is out of bounds.
If you need to loop over all the pointers, prefer the pointers()
method.
sourcepub fn history_size(&self) -> usize
pub fn history_size(&self) -> usize
Returns the size of the history contained in this event.
See the NDK docs
sourcepub fn history(&self) -> HistoricalMotionEventsIter<'_>ⓘNotable traits for HistoricalMotionEventsIter<'a>impl<'a> Iterator for HistoricalMotionEventsIter<'a> type Item = HistoricalMotionEvent<'a>;
pub fn history(&self) -> HistoricalMotionEventsIter<'_>ⓘNotable traits for HistoricalMotionEventsIter<'a>impl<'a> Iterator for HistoricalMotionEventsIter<'a> type Item = HistoricalMotionEvent<'a>;
An iterator over the historical events contained in this event.
sourcepub fn meta_state(&self) -> MetaState
pub fn meta_state(&self) -> MetaState
Returns the state of any modifier keys that were pressed during the event.
See the NDK docs
Returns the button state during this event, as a bitfield.
See the NDK docs
sourcepub fn down_time(&self) -> i64
pub fn down_time(&self) -> i64
Returns the time of the start of this gesture, in the java.lang.System.nanoTime()
time
base
See the NDK docs
sourcepub fn edge_flags(&self) -> EdgeFlags
pub fn edge_flags(&self) -> EdgeFlags
Returns a bitfield indicating which edges were touched by this event.
See the NDK docs
sourcepub fn event_time(&self) -> i64
pub fn event_time(&self) -> i64
Returns the time of this event, in the java.lang.System.nanoTime()
time base
See the NDK docs
sourcepub fn flags(&self) -> MotionEventFlags
pub fn flags(&self) -> MotionEventFlags
The flags associated with a motion event.
See the NDK docs
sourcepub fn x_offset(&self) -> f32
pub fn x_offset(&self) -> f32
Returns the offset in the x direction between the coordinates and the raw coordinates
See the NDK docs
sourcepub fn y_offset(&self) -> f32
pub fn y_offset(&self) -> f32
Returns the offset in the y direction between the coordinates and the raw coordinates
See the NDK docs
sourcepub fn x_precision(&self) -> f32
pub fn x_precision(&self) -> f32
Returns the precision of the x value of the coordinates
See the NDK docs
sourcepub fn y_precision(&self) -> f32
pub fn y_precision(&self) -> f32
Returns the precision of the y value of the coordinates
See the NDK docs
Trait Implementations
sourceimpl Clone for MotionEvent
impl Clone for MotionEvent
sourcefn clone(&self) -> MotionEvent
fn clone(&self) -> MotionEvent
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for MotionEvent
impl !Send for MotionEvent
impl !Sync for MotionEvent
impl Unpin for MotionEvent
impl UnwindSafe for MotionEvent
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more