MotionEvent MotionEvent Class

Definition

Object used to report movement (mouse, pen, finger, trackball) events.

[Android.Runtime.Register("android/view/MotionEvent", ApiSince=1, DoNotGenerateAcw=true)]
public sealed class MotionEvent : Android.Views.InputEvent, IDisposable
type MotionEvent = class
    inherit InputEvent
    interface IParcelable
    interface IJavaObject
    interface IDisposable
Inheritance
Attributes
Implements

Remarks

Android platform documentation

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Fields

ButtonBack ButtonBack

Button constant: Back button pressed (mouse back button).

ButtonForward ButtonForward

Button constant: Forward button pressed (mouse forward button).

ButtonPrimary ButtonPrimary

Button constant: Primary button (left mouse button).

ButtonSecondary ButtonSecondary

Button constant: Secondary button (right mouse button).

ButtonStylusPrimary ButtonStylusPrimary
ButtonStylusSecondary ButtonStylusSecondary
ButtonTertiary ButtonTertiary

Button constant: Tertiary button (middle mouse button).

FlagWindowIsObscured FlagWindowIsObscured

This flag indicates that the window that received this motion event is partly or wholly obscured by another visible window above it.

InvalidPointerId InvalidPointerId

An invalid pointer id.

ToolTypeEraser ToolTypeEraser

Tool type constant: The tool is an eraser or a stylus being used in an inverted posture.

ToolTypeFinger ToolTypeFinger

Tool type constant: The tool is a finger.

ToolTypeMouse ToolTypeMouse

Tool type constant: The tool is a mouse or trackpad.

ToolTypeStylus ToolTypeStylus

Tool type constant: The tool is a stylus.

ToolTypeUnknown ToolTypeUnknown

Tool type constant: Unknown tool type.

Properties

Action Action

Return the kind of action being performed.

ActionButton ActionButton
ActionIndex ActionIndex

For Android.Views.MotionEvent.ACTION_POINTER_DOWN or Android.Views.MotionEvent.ACTION_POINTER_UP as returned by ActionMasked, this returns the associated pointer index.

ActionMasked ActionMasked

Return the masked action being performed, without pointer index information.

ButtonState ButtonState

Gets the state of all buttons that are pressed such as a mouse or stylus button.

Class Class

Returns the unique instance of Class that represents this object's class.

(Inherited from Object)
Creator Creator
Device Device

Gets the device that this event came from.

(Inherited from InputEvent)
DeviceId DeviceId

Gets the id for the device that this event came from.

DownTime DownTime

Returns the time (in ms) when the user originally pressed down to start a stream of position events.

EdgeFlags EdgeFlags

Returns a bitfield indicating which edges, if any, were touched by this MotionEvent.

EventTime EventTime

Retrieve the time this event occurred, in the UptimeMillis() time base.

Flags Flags

Gets the motion event flags.

Handle Handle

The handle to the underlying Android instance.

(Inherited from Object)
HistorySize HistorySize

Returns the number of historical points in this event.

IJavaObjectEx.IsProxy IJavaObjectEx.IsProxy Inherited from Object
IJavaObjectEx.KeyHandle IJavaObjectEx.KeyHandle Inherited from Object
IJavaObjectEx.NeedsActivation IJavaObjectEx.NeedsActivation Inherited from Object
IJavaPeerable.JniManagedPeerState IJavaPeerable.JniManagedPeerState Inherited from Object
JniIdentityHashCode JniIdentityHashCode Inherited from Object
JniPeerMembers JniPeerMembers
MetaState MetaState

Returns the state of any meta / modifier keys that were in effect when the event was generated.

Orientation Orientation

GetOrientation(Int32) for the first pointer index (may be an arbitrary pointer identifier).

PeerReference PeerReference Inherited from Object
PointerCount PointerCount

The number of pointers of data contained in this event.

Pressure Pressure

GetPressure(Int32) for the first pointer index (may be an arbitrary pointer identifier).

RawX RawX

Returns the original raw X coordinate of this event.

RawY RawY

Returns the original raw Y coordinate of this event.

Size Size

GetSize(Int32) for the first pointer index (may be an arbitrary pointer identifier).

Source Source

Gets the source of the event.

ThresholdClass ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from InputEvent)
ThresholdType ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from InputEvent)
ToolMajor ToolMajor

GetToolMajor(Int32) for the first pointer index (may be an arbitrary pointer identifier).

ToolMinor ToolMinor

GetToolMinor(Int32) for the first pointer index (may be an arbitrary pointer identifier).

TouchMajor TouchMajor

GetTouchMajor(Int32) for the first pointer index (may be an arbitrary pointer identifier).

TouchMinor TouchMinor

GetTouchMinor(Int32) for the first pointer index (may be an arbitrary pointer identifier).

XPrecision XPrecision

Return the precision of the X coordinates being reported.

YPrecision YPrecision

Return the precision of the Y coordinates being reported.

Methods

ActionToString(MotionEventActions) ActionToString(MotionEventActions)

Returns a string that represents the symbolic name of the specified unmasked action such as "ACTION_DOWN", "ACTION_POINTER_DOWN(3)" or an equivalent numeric constant such as "35" if unknown.

AddBatch(Int64, MotionEvent+PointerCoords[], MetaKeyStates) AddBatch(Int64, MotionEvent+PointerCoords[], MetaKeyStates)

Add a new movement to the batch of movements in this event.

AddBatch(Int64, Single, Single, Single, Single, MetaKeyStates) AddBatch(Int64, Single, Single, Single, Single, MetaKeyStates)

Add a new movement to the batch of movements in this event.

AxisFromString(String) AxisFromString(String)

Gets an axis by its symbolic name such as "AXIS_X" or an equivalent numeric constant such as "42".

AxisToString(Axis) AxisToString(Axis)

Returns a string that represents the symbolic name of the specified axis such as "AXIS_X" or an equivalent numeric constant such as "42" if unknown.

Clone() Clone()

Creates and returns a copy of this Object.

(Inherited from Object)
DescribeContents() DescribeContents()

Describe the kinds of special objects contained in this Parcelable's marshalled representation.

(Inherited from InputEvent)
Dispose() Dispose() Inherited from Object
Dispose(Boolean) Dispose(Boolean) Inherited from Object
Equals(Object) Equals(Object)

Compares this instance with the specified object and indicates if they are equal.

(Inherited from Object)
FindPointerIndex(Int32) FindPointerIndex(Int32)

Given a pointer identifier, find the index of its data in the event.

GetAxisValue(Axis) GetAxisValue(Axis)

GetAxisValue(Axis) for the first pointer index (may be an arbitrary pointer identifier).

GetAxisValue(Axis, Int32) GetAxisValue(Axis, Int32)

Returns the value of the requested axis for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetHashCode() GetHashCode()

Returns an integer hash code for this object.

(Inherited from Object)
GetHistoricalAxisValue(Axis, Int32) GetHistoricalAxisValue(Axis, Int32)

GetHistoricalAxisValue(Axis, Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalAxisValue(Axis, Int32, Int32) GetHistoricalAxisValue(Axis, Int32, Int32)

Returns the historical value of the requested axis, as per GetAxisValue(Axis, Int32), occurred between this event and the previous event for the given pointer.

GetHistoricalEventTime(Int32) GetHistoricalEventTime(Int32)

Returns the time that a historical movement occurred between this event and the previous event, in the UptimeMillis() time base.

GetHistoricalOrientation(Int32) GetHistoricalOrientation(Int32)

GetHistoricalOrientation(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalOrientation(Int32, Int32) GetHistoricalOrientation(Int32, Int32)

Returns a historical orientation coordinate, as per GetOrientation(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalPointerCoords(Int32, Int32, MotionEvent+PointerCoords) GetHistoricalPointerCoords(Int32, Int32, MotionEvent+PointerCoords)

Populates a MotionEvent PointerCoords object with historical pointer coordinate data, as per GetPointerCoords(Int32, MotionEvent+PointerCoords), that occurred between this event and the previous event for the given pointer.

GetHistoricalPressure(Int32) GetHistoricalPressure(Int32)

GetHistoricalPressure(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalPressure(Int32, Int32) GetHistoricalPressure(Int32, Int32)

Returns a historical pressure coordinate, as per GetPressure(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalSize(Int32) GetHistoricalSize(Int32)

GetHistoricalSize(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalSize(Int32, Int32) GetHistoricalSize(Int32, Int32)

Returns a historical size coordinate, as per GetSize(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalToolMajor(Int32) GetHistoricalToolMajor(Int32)

GetHistoricalToolMajor(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalToolMajor(Int32, Int32) GetHistoricalToolMajor(Int32, Int32)

Returns a historical tool major axis coordinate, as per GetToolMajor(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalToolMinor(Int32) GetHistoricalToolMinor(Int32)

GetHistoricalToolMinor(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalToolMinor(Int32, Int32) GetHistoricalToolMinor(Int32, Int32)

Returns a historical tool minor axis coordinate, as per GetToolMinor(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalTouchMajor(Int32) GetHistoricalTouchMajor(Int32)

GetHistoricalTouchMajor(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalTouchMajor(Int32, Int32) GetHistoricalTouchMajor(Int32, Int32)

Returns a historical touch major axis coordinate, as per GetTouchMajor(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalTouchMinor(Int32) GetHistoricalTouchMinor(Int32)

GetHistoricalTouchMinor(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalTouchMinor(Int32, Int32) GetHistoricalTouchMinor(Int32, Int32)

Returns a historical touch minor axis coordinate, as per GetTouchMinor(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalX(Int32) GetHistoricalX(Int32)

GetHistoricalX(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalX(Int32, Int32) GetHistoricalX(Int32, Int32)

Returns a historical X coordinate, as per GetX(Int32), that occurred between this event and the previous event for the given pointer.

GetHistoricalY(Int32) GetHistoricalY(Int32)

GetHistoricalY(Int32, Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetHistoricalY(Int32, Int32) GetHistoricalY(Int32, Int32)

Returns a historical Y coordinate, as per GetY(Int32), that occurred between this event and the previous event for the given pointer.

GetOrientation(Int32) GetOrientation(Int32)

Returns the orientation of the touch area and tool area in radians clockwise from vertical for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetPointerCoords(Int32, MotionEvent+PointerCoords) GetPointerCoords(Int32, MotionEvent+PointerCoords)

MotionEvent PointerCoords

GetPointerId(Int32) GetPointerId(Int32)

Return the pointer identifier associated with a particular pointer data index is this event.

GetPointerProperties(Int32, MotionEvent+PointerProperties) GetPointerProperties(Int32, MotionEvent+PointerProperties)

MotionEvent PointerProperties

GetPressure(Int32) GetPressure(Int32)

Returns the current pressure of this event for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetSize(Int32) GetSize(Int32)

Returns a scaled value of the approximate size for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetToolMajor(Int32) GetToolMajor(Int32)

Returns the length of the major axis of an ellipse that describes the size of the approaching tool for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetToolMinor(Int32) GetToolMinor(Int32)

Returns the length of the minor axis of an ellipse that describes the size of the approaching tool for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetToolType(Int32) GetToolType(Int32)

Gets the tool type of a pointer for the given pointer index.

GetTouchMajor(Int32) GetTouchMajor(Int32)

Returns the length of the major axis of an ellipse that describes the touch area at the point of contact for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetTouchMinor(Int32) GetTouchMinor(Int32)

Returns the length of the minor axis of an ellipse that describes the touch area at the point of contact for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetX() GetX()

GetX(Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetX(Int32) GetX(Int32)

Returns the X coordinate of this event for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

GetY() GetY()

GetY(Int32) for the first pointer index (may be an arbitrary pointer identifier).

GetY(Int32) GetY(Int32)

Returns the Y coordinate of this event for the given pointer index (use GetPointerId(Int32) to find the pointer identifier for this index).

IsButtonPressed(MotionEventButtonState) IsButtonPressed(MotionEventButtonState)

Checks if a mouse or stylus button (or combination of buttons) is pressed.

IsFromSource(InputSourceType) IsFromSource(InputSourceType)

Determines whether the event is from the given source.

(Inherited from InputEvent)
JavaFinalize() JavaFinalize()

Invoked when the garbage collector has detected that this instance is no longer reachable.

(Inherited from Object)
Notify() Notify()

Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
NotifyAll() NotifyAll()

Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.

(Inherited from Object)
Obtain(Int64, Int64, Int32, Int32, Int32[], MotionEvent+PointerCoords[], MetaKeyStates, Single, Single, Int32, Edge, Int32, Int32) Obtain(Int64, Int64, Int32, Int32, Int32[], MotionEvent+PointerCoords[], MetaKeyStates, Single, Single, Int32, Edge, Int32, Int32)
Obtain(Int64, Int64, Int32, Int32, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge) Obtain(Int64, Int64, Int32, Int32, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge)
Obtain(Int64, Int64, Int32, Single, Single, MetaKeyStates) Obtain(Int64, Int64, Int32, Single, Single, MetaKeyStates)
Obtain(Int64, Int64, Int32, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge) Obtain(Int64, Int64, Int32, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge)
Obtain(Int64, Int64, MotionEventActions, Int32, Int32[], MotionEvent+PointerCoords[], MetaKeyStates, Single, Single, Int32, Edge, InputSourceType, MotionEventFlags) Obtain(Int64, Int64, MotionEventActions, Int32, Int32[], MotionEvent+PointerCoords[], MetaKeyStates, Single, Single, Int32, Edge, InputSourceType, MotionEventFlags)

Create a new MotionEvent, filling in all of the basic values that define the motion.

Obtain(Int64, Int64, MotionEventActions, Int32, MotionEvent+PointerProperties[], MotionEvent+PointerCoords[], MetaKeyStates, MotionEventButtonState, Single, Single, Int32, Edge, InputSourceType, MotionEventFlags) Obtain(Int64, Int64, MotionEventActions, Int32, MotionEvent+PointerProperties[], MotionEvent+PointerCoords[], MetaKeyStates, MotionEventButtonState, Single, Single, Int32, Edge, InputSourceType, MotionEventFlags)

Create a new MotionEvent, filling in all of the basic values that define the motion.

Obtain(Int64, Int64, MotionEventActions, Int32, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge) Obtain(Int64, Int64, MotionEventActions, Int32, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge)

Create a new MotionEvent, filling in all of the basic values that define the motion.

Obtain(Int64, Int64, MotionEventActions, Single, Single, MetaKeyStates) Obtain(Int64, Int64, MotionEventActions, Single, Single, MetaKeyStates)

Create a new MotionEvent, filling in a subset of the basic motion values.

Obtain(Int64, Int64, MotionEventActions, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge) Obtain(Int64, Int64, MotionEventActions, Single, Single, Single, Single, MetaKeyStates, Single, Single, Int32, Edge)

Create a new MotionEvent, filling in all of the basic values that define the motion.

Obtain(MotionEvent) Obtain(MotionEvent)

Create a new MotionEvent, copying from an existing one.

ObtainNoHistory(MotionEvent) ObtainNoHistory(MotionEvent)

Create a new MotionEvent, copying from an existing one, but not including any historical point information.

OffsetLocation(Single, Single) OffsetLocation(Single, Single)

Adjust this event's location.

Recycle() Recycle()

Recycle the MotionEvent, to be re-used by a later caller.

SetHandle(IntPtr, JniHandleOwnership) SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLocation(Single, Single) SetLocation(Single, Single)

Set this event's location.

SetSource(InputSourceType) SetSource(InputSourceType)

Modifies the source of the event.

ToArray<T>() ToArray<T>() Inherited from Object
ToString() ToString()

Returns a string containing a concise, human-readable description of this object.

(Inherited from Object)
Transform(Matrix) Transform(Matrix)

Applies a transformation matrix to all of the points in the event.

UnregisterFromRuntime() UnregisterFromRuntime() Inherited from Object
Wait() Wait()

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.

(Inherited from Object)
Wait(Int64) Wait(Int64)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
Wait(Int64, Int32) Wait(Int64, Int32)

Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.

(Inherited from Object)
WriteToParcel(Parcel, ParcelableWriteFlags) WriteToParcel(Parcel, ParcelableWriteFlags)

Flatten this object in to a Parcel.

Explicit Interface Implementations

IJavaObjectEx.ToLocalJniHandle() IJavaObjectEx.ToLocalJniHandle() Inherited from Object
IJavaPeerable.Disposed() IJavaPeerable.Disposed() Inherited from Object
IJavaPeerable.DisposeUnlessReferenced() IJavaPeerable.DisposeUnlessReferenced() Inherited from Object
IJavaPeerable.Finalized() IJavaPeerable.Finalized() Inherited from Object
IJavaPeerable.SetJniIdentityHashCode(Int32) IJavaPeerable.SetJniIdentityHashCode(Int32) Inherited from Object
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) Inherited from Object
IJavaPeerable.SetPeerReference(JniObjectReference) IJavaPeerable.SetPeerReference(JniObjectReference) Inherited from Object

Extension Methods

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject) JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable) GetJniTypeName(IJavaPeerable)

Applies to