Struct android_activity::input::MotionEvent

source ·
pub struct MotionEvent<'a> { /* private fields */ }
Expand description

A motion event

For general discussion of motion events in Android, see the relevant javadoc.

Implementations§

source§

impl<'a> MotionEvent<'a>

source

pub fn source(&self) -> Source

Get the source of the event.

source

pub fn device_id(&self) -> i32

Get the device id associated with the event.

source

pub fn action(&self) -> MotionAction

Returns the motion action associated with the event.

See the MotionEvent docs

source

pub fn action_button(&self) -> Button

Returns which button has been modified during a press or release action.

For actions other than MotionAction::ButtonPress and MotionAction::ButtonRelease the returned value is undefined.

See the MotionEvent docs

source

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.

source

pub fn pointer_count(&self) -> usize

Returns the number of pointers in this event

See the MotionEvent docs

source

pub fn pointers(&self) -> PointersIter<'_>

An iterator over the pointers in this motion event

source

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.

source

pub fn meta_state(&self) -> MetaState

Returns the state of any modifier keys that were pressed during the event.

See the NDK docs

source

pub fn button_state(&self) -> ButtonState

Returns the button state during this event, as a bitfield.

See the NDK docs

source

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

source

pub fn edge_flags(&self) -> EdgeFlags

Returns a bitfield indicating which edges were touched by this event.

See the NDK docs

source

pub fn event_time(&self) -> i64

Returns the time of this event, in the java.lang.System.nanoTime() time base

See the NDK docs

source

pub fn flags(&self) -> MotionEventFlags

The flags associated with a motion event.

See the NDK docs

source

pub fn x_precision(&self) -> f32

Returns the precision of the x value of the coordinates

See the NDK docs

source

pub fn y_precision(&self) -> f32

Returns the precision of the y value of the coordinates

See the NDK docs

Trait Implementations§

source§

impl<'a> Debug for MotionEvent<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for MotionEvent<'a>

§

impl<'a> RefUnwindSafe for MotionEvent<'a>

§

impl<'a> !Send for MotionEvent<'a>

§

impl<'a> !Sync for MotionEvent<'a>

§

impl<'a> Unpin for MotionEvent<'a>

§

impl<'a> UnwindSafe for MotionEvent<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.