Pointer

Pointer

Class for Pointer objects. When a Pointer object is passed to the Action constructor: var actions = new Actions(new Actions.Pointer('bigMouse'))

the action's tick will have the following methods (assuming that the Pointer's ID is mouse):

Note: input device objects are only ever used in Actions

Constructor

new Pointer(id, pointerType)

Each device is associated a unique ID like mouse, touch, pen.

Parameters:
Name Type Description
id string

The unique ID of the device

pointerType string

It can be Pointer.Type.MOUSE, Pointer.Type.PEN or Pointer.Type.TOUCH

Source:
Example
var mouse = new Actions.Pointer('mouse', Pointer.Type.MOUSE)
var touch1 = new Actions.Pointer('touch1', Pointer.Type.TOUCH)
var touch2 = new Actions.Pointer('touch2', Pointer.Type.TOUCH)
var actions = new Actions(mouse, touch1, touch2)
actions.tick.mouseDown().touch1Down().touch2Down()

Extends

Members

(static) Type

The types of pointer types, used to create the right type of pointer. E.g. Pointer.Type.MOUSE, Pointer.Type.PEN or Pointer.Type.TOUCH,

It actually returns:

 {
   MOUSE: 'mouse',
   PEN: 'pen',
   TOUCH: 'touch'
 }
Source:

(static) Button

The button types on a pointer.

It actually returns:

{ LEFT: 0, MIDDLE: 1, RIGHT: 2 }

Source:

(static) Origin

The types of origins, used in Move() commands. See Actions on how to use this constant. E.g. Pointer.Origin.VIEWPORT or Pointer.Origin.POINTER

It actually returns:

{
  VIEWPORT: 'viewport',
  POINTER: 'pointer'
}
Source:

Methods

Move(params)

Move the pointer to a specified origin location, using x and y and offset, and taking duration milliseconds

This method will be added to the action's tick property. prefixed with the Pointer's ID.

Parameters:
Name Type Description
params Object

Instructions on where to move the pointer

Properties
Name Type Default Description
origin Element | string Pointer.Origin.VIEWPORT

Where to move the pointer to. It can be an Element object, or Pointer.Origin.VIEWPORT or Pointer.Origin.POINTER

x number

The x offset, from params.origin.

y number

The y offset, from params.origin.

duration number

How long the operation will take, in milliseconds

Source:
Example
// Defining a pointer device called "cucumber", and passing it
    // to the actions constructor
    var actions = new Actions( new Actions.Pointer('bigMouse'))
    // the `cucumberMove` method is now available in the tick property
    actions.tick.bigMouseMove({ x: 400, y: 400 })

Down(button)

Press a pointer button

This method will be added to the action's tick property. prefixed with the Pointer's ID.

Parameters:
Name Type Default Description
button number Pointer.Button.LEFT

The button to press. It can be Pointer.Button.LEFT (0), Pointer.Button.MIDDLE (1) or Pointer.Button.RIGHT (2)

Source:
Example
var actions = new Actions( new Actions.Pointer('bigMouse'))
    actions.tick.bigMouseDown()
    actions.tick.bigMouseDown(Pointer.Button.RIGHT)

Up(button)

Release a pointer button

This method will be added to the action's tick property. prefixed with the Pointer's ID.

Parameters:
Name Type Default Description
button number Pointer.Button.LEFT

The button to let go

Source:
Example
var actions = new Actions( new Actions.Pointer('bigMouse'))
    actions.tick.bigMouseUp()
    actions.tick.bigMouseUp(Pointer.Button.RIGHT)

Cancel()

Cancels the pointer

This method will be added to the action's tick property. prefixed with the Pointer's ID.

Source:
Example
var bigMouse = new Actions.Pointer('bigMouse')

    // This will take 4 seconds. NOTE: there is no await before actions.performActions
    var actions = new Actions(bigMouse)
    actions.tick.bigMouseDown().tick.bigMouseUp().tick.bigMouseCancel()

Pause(duration)

Pause the pointer for the specified length of time

This method will be added to the action's tick property. prefixed with the Pointer's ID.

Parameters:
Name Type Default Description
duration number 0

Duration of the pause

Source:
Example
var bigMouse = new Actions.Pointer('bigMouse')
   var bigKeyboard = new Actions.Keyboard('bigKeyboard')

   var actions = new Actions(bigMouse, bigKeyboard)
   actions.tick.bigKeyboardDown('a').bigMousePause()
   actions.performActions(actions)