pub struct MotionEvent { /* private fields */ }
Expand description
A motion event.
For general discussion of motion events in Android, see the relevant javadoc.
Implementations§
Source§impl 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 AInputEvent
By calling this method, you assert that the pointer is a valid, non-null pointer to a
native AInputEvent
, and that that AInputEvent
is an AMotionEvent
.
Sourcepub fn ptr(&self) -> NonNull<AInputEvent>
pub fn ptr(&self) -> NonNull<AInputEvent>
Returns a pointer to the native 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 this 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_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<'_> ⓘ
pub fn pointers(&self) -> PointersIter<'_> ⓘ
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<'_> ⓘ
pub fn history(&self) -> HistoricalMotionEventsIter<'_> ⓘ
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§
Auto Trait Implementations§
impl Freeze for MotionEvent
impl RefUnwindSafe for MotionEvent
impl !Send for MotionEvent
impl !Sync for MotionEvent
impl Unpin for MotionEvent
impl UnwindSafe for MotionEvent
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more