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§
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 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 unsafe fn from_java(
env: *mut JNIEnv,
key_event: jobject,
) -> Option<InputEventJava>
Available on crate feature api-level-31
only.
pub unsafe fn from_java( env: *mut JNIEnv, key_event: jobject, ) -> Option<InputEventJava>
api-level-31
only.Creates a native InputEvent
object that is a copy of the specified
Java android.view.MotionEvent
. The result may be used with generic and
MotionEvent
-specific functions.
§Safety
This function should be called with a healthy JVM pointer and with a non-null
android.view.MotionEvent
.
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<'_> ⓘ
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§
Source§impl Clone for MotionEvent
impl Clone for MotionEvent
Source§fn clone(&self) -> MotionEvent
fn clone(&self) -> MotionEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more