跳到主要内容

MotionEvent

declare class MotionEvent {}

Object used to report movement (mouse, finger) events. Motion events may hold either absolute or relative movements and other data,

Static Property

ACTION_DOWN

declare class MotionEvent {
static ACTION_DOWN: number
}
  • Description

    A pressed gesture has started, the motion contains the initial starting location.

ACTION_UP

declare class MotionEvent {
static ACTION_UP: number
}
  • Description

    A pressed gesture has finished, the motion contains the final release location as well as any intermediate points since the last down or move event.

ACTION_MOVE

declare class MotionEvent {
static ACTION_MOVE: number
}
  • Description

    A change has happened during a press gesture (between ACTION_DOWN and ACTION_UP).

ACTION_CANCEL

declare class MotionEvent {
static ACTION_CANCEL: number
}
  • Description

    The current gesture has been aborted.

ACTION_SCROLL

declare class MotionEvent {
static ACTION_SCROLL: number
}
  • Description

    The motion event contains relative vertical and/or horizontal scroll offsets.

AXIS_VSCROLL

declare class MotionEvent {
static AXIS_VSCROLL: number
}
  • Description

    Axis constant: Vertical Scroll axis of a motion event.

AXIS_HSCROLL

declare class MotionEvent {
static AXIS_HSCROLL: number
}
  • Description

    Axis constant: Horizontal Scroll axis of a motion event.

ACTION_HOVER_ENTER

declare class MotionEvent {
static ACTION_HOVER_ENTER: number
}
  • Description

    The pointer is not down but has entered the boundaries of a window or view.

ACTION_HOVER_MOVE

declare class MotionEvent {
static ACTION_HOVER_MOVE: number
}
  • Description

    A change happened but the pointer is not down (unlike ACTION_MOVE).

ACTION_HOVER_EXIT

declare class MotionEvent {
static ACTION_HOVER_EXIT: number
}
  • Description

    The pointer is not down but has exited the boundaries of a window or view.

Instance Method

getDownTime

declare class MotionEvent {
getDownTime(): number
}
  • Description

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

getEventTimeNano

declare class MotionEvent {
getEventTimeNano(): number
}
  • Description

    Retrieve the time this event occurred.

getAxisValue

declare class MotionEvent {
getAxisValue(axis: number): number
}
  • Description

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

getPointerId

declare class MotionEvent {
getPointerId(pointerIndex: number): number
}
  • Description

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

getPointerCount

declare class MotionEvent {
getPointerCount(): number
}
  • Description

    The number of pointers of data contained in this event.

getX

declare class MotionEvent {
getX(): number
}
  • Description

    Equivalent to getX(int) for pointer index 0 (regardless of the pointer identifier).

getX

declare class MotionEvent {
getX(index: number): number
}
  • Description

    Returns the X coordinate of the pointer referenced by pointerIndex for this motion event.

getY

declare class MotionEvent {
getY(): number
}
  • Description

    Equivalent to getY(int) for pointer index 0 (regardless of the pointer identifier).

getY

declare class MotionEvent {
getY(index: number): number
}
  • Description

    Returns the Y coordinate of the pointer referenced by pointerIndex for this motion event.

getRawX

declare class MotionEvent {
getRawX(): number
}
  • Description

    Equivalent to getRawX(int) for pointer index 0 (regardless of the pointer identifier).

getRawX

declare class MotionEvent {
getRawX(index: number): number
}
  • Description

    Returns the X coordinate of the pointer referenced by pointerIndex for this motion event.

getRawY

declare class MotionEvent {
getRawY(): number
}
  • Description

    Equivalent to getRawY(int) for pointer index 0 (regardless of the pointer identifier).

getRawY

declare class MotionEvent {
getRawY(index: number): number
}
  • Description

    Returns the Y coordinate of the pointer referenced by pointerIndex for this motion event.

getAction

declare class MotionEvent {
getAction(): number
}
  • Description

    Return the kind of action being performed.

findPointerIndex

declare class MotionEvent {
findPointerIndex(pointerId: number): number
}
  • Description

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

getActionMasked

declare class MotionEvent {
getActionMasked(): number
}
  • Description

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

getPointerCoords

declare class MotionEvent {
getPointerCoords(pointerIndex: number, outPointerCoords: MotionEvent.PointerCoords): void
}
  • Description

    Populates a PointerCoords object with pointer coordinate data for the specified pointer index.




MotionEvent.PointerCoords

Transfer object for pointer coordinates. Objects of this type can be used to specify the pointer coordinates when creating new MotionEvent objects and to query pointer coordinates in bulk.

declare class PointerCoords {}

Instance Property

x

declare interface PointerCoords {
x: number;
}
  • Description

    The X component of the pointer movement.

y

declare interface PointerCoords {
y: number;
}
  • Description

    The Y component of the pointer movement.