# Class: Pointer

## Pointer(domElement, canvas)

#### new Pointer(domElement, canvas)

Pointer object is used to called input from the user, works for booth mouse or touch screens. It is responsible for synchronizing user input with the render of the graphics.

##### Parameters:

Name | Type | Description
--- | --- | ---
`domElement` | Element | DOM element to create the pointer events.
`canvas` | Element | Canvas DOM element where the content is being drawn.

Source:
  - input/Pointer.js, line 14

### Members

#### (static) BACK :number

Back pointer navigation button.

##### Type:

- number

Source:
  - input/Pointer.js, line 237

#### (static) FORWARD :number

Forward pointer navigation button.

##### Type:

- number

Source:
  - input/Pointer.js, line 245

#### (static) LEFT :number

Left pointer button.

##### Type:

- number

Source:
  - input/Pointer.js, line 213

#### (static) MIDDLE :number

Middle pointer button.

##### Type:

- number

Source:
  - input/Pointer.js, line 221

#### (static) RIGHT :number

Right pointer button.

##### Type:

- number

Source:
  - input/Pointer.js, line 229

#### canvas :Element

Canvas attached to this pointer instance used to calculate position and delta in element space coordinates.

##### Type:

- Element

Source:
  - input/Pointer.js, line 76

#### delta :Vector2

Pointer movement (coordinates in window space). Since the last update. This value is accumulated from multiple mouse triggered events between updated.

##### Type:

- Vector2

Source:
  - input/Pointer.js, line 48

#### domElement :Element

DOM element where to attach the pointer events.

##### Type:

- Element

Source:
  - input/Pointer.js, line 69

#### doubleClicked :boolean

Indicates a button of the pointer was double clicked.

##### Type:

- boolean

Source:
  - input/Pointer.js, line 62

#### events :EventManager

Event manager responsible for updating the raw data variables. Different events are used depending on the host platform. When the update method is called the raw data is reset.

##### Type:

- EventManager

Source:
  - input/Pointer.js, line 91

#### keys :Array.<number>

Array with pointer buttons status.

##### Type:

- Array.<number>

Source:
  - input/Pointer.js, line 30

#### position :Vector2

Pointer position inside of the window (coordinates in window space). This value is accumulated from multiple mouse triggered events between updated.

##### Type:

- Vector2

Source:
  - input/Pointer.js, line 39

#### wheel :number

Pointer scroll wheel movement, since the last update.

##### Type:

- number

Source:
  - input/Pointer.js, line 55

### Methods

#### (static) buttonDoubleClicked(button) → {boolean}

Check if pointer button was double clicked.

##### Parameters:

Name | Type | Description
--- | --- | ---
`button` | Number | Button to check status of

Source:
  - input/Pointer.js, line 296

##### Returns:

True if some pointer button was just double clicked

Type
  boolean

#### (static) buttonJustPressed(button) → {boolean}

Check if a pointer button was just pressed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`button` | Number | Button to check status of

Source:
  - input/Pointer.js, line 307

##### Returns:

True if button was just pressed

Type
  boolean

#### (static) buttonJustReleased(button) → {boolean}

Check if a pointer button was just released.

##### Parameters:

Name | Type | Description
--- | --- | ---
`button` | Number | Button to check status of

Source:
  - input/Pointer.js, line 318

##### Returns:

True if button was just released

Type
  boolean

#### (static) buttonPressed(button) → {boolean}

Check if pointer button is currently pressed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`button` | Number | Button to check status of

Source:
  - input/Pointer.js, line 285

##### Returns:

True if button is currently pressed

Type
  boolean

#### (static) create()

Create pointer events to collect input data. Should be called before using the pointer object.

Source:
  - input/Pointer.js, line 425

#### (static) dispose()

Dispose pointer events, should be called after the objects is no longer required. If not called leaves the window events created leaving a memory/code leak.

Source:
  - input/Pointer.js, line 435

#### (static) insideCanvas() → {boolean}

Check if pointer is inside attached canvas (updated async).

Source:
  - input/Pointer.js, line 274

##### Returns:

True if pointer is currently inside the canvas

Type
  boolean

#### (static) setCanvas(element)

Element to be used for coordinates calculation relative to that canvas.

##### Parameters:

Name | Type | Description
--- | --- | ---
`element` | DOM | Canvas to be attached to the Pointer instance

Source:
  - input/Pointer.js, line 252

#### (static) update()

Update pointer buttons state, position, wheel and delta synchronously. Should be called every frame on the update loop before reading any values from the pointer.

Source:
  - input/Pointer.js, line 365

#### (static) updateKey(button, action)

Update a pointer button.

##### Parameters:

Name | Type | Description
--- | --- | ---
`button` | Number |
`action` | Number |

Source:
  - input/Pointer.js, line 352

#### (static) updatePosition(x, y, xDiff, yDiff)

Update pointer position.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | Number |
`y` | Number |
`xDiff` | Number |
`yDiff` | Number |

Source:
  - input/Pointer.js, line 331