Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Controls

Help class for creating user controls.

class
constructor

Hierarchy

  • Controls

Index

Constructors

constructor

Properties

Private _blurHandlers

_blurHandlers: Function[] = []

Private _focusHandlers

_focusHandlers: Function[] = []

Private _focusOnlyIfClick

_focusOnlyIfClick: boolean = true

Set focus only if canvas clicked like on default input or button. If [true] then you need to click on canvas before it will be focused. If [false] then you just need to move your cursor over canvas.

type

{boolean}

default

true

Private _globalRebind

_globalRebind: boolean = false

Private _handlers

_handlers: Array<Function | null> = []

Functions which triggers if key pressed.

Private _lockPointer

_lockPointer: boolean = false

Private _mouseDownHandlers

_mouseDownHandlers: Function[] | null[] = [null,null,null,null,null,null]

Functions which triggers if mouse button pressed.

Private _mouseUpHandlers

_mouseUpHandlers: Function[] | null[] = [null,null,null,null,null,null]

Functions which triggers if mouse button pressed.

Private _rebind

_rebind: boolean = true

Rebind default key events

default

true

controlFunction

controlFunction: Function | null = null

engine

engine: Engine

isFocused

isFocused: boolean = false

True if canvas focused.

keys

keys: boolean[] = []

True if keys pressed. False if not.

longTouchTime

longTouchTime: number = 500

The time that the user must spend on a long press. A long press counts as a right mouse click.

mouse

mouse: Mouse = new Mouse()

mouseOverCanvas

mouseOverCanvas: boolean = false

True if mouse cursor over canvas element.

pointerLocked

pointerLocked: boolean = false

touch

touch: Touch = new Touch()

touchDuration

touchDuration: number = 100

Methods

addOnBlurHandler

  • addOnBlurHandler(handler: Function): void
  • Adds handler which will execute on canvas blur.

    Parameters

    • handler: Function

    Returns void

addOnFocusHandler

  • addOnFocusHandler(handler: Function): void
  • Adds handler which will execute on canvas focus.

    Parameters

    • handler: Function

    Returns void

clickForFocus

  • clickForFocus(bool: boolean): void
  • Sets mode when user need click to focus canvas

    Parameters

    • bool: boolean

    Returns void

globalRebind

  • globalRebind(bool: boolean): void
  • Rebind default browser shortcut actions on all page. By default rebind occurs only if canvas focused.

    default

    false

    Parameters

    • bool: boolean

    Returns void

lockPointer

  • lockPointer(bool: boolean): void
  • Lock pointer on canvas. Useful for FPS Games.

    default

    true

    Parameters

    • bool: boolean

    Returns void

onContextMenu

  • onContextMenu(handler: function | null): void
  • Sets function on right click for context menu.

    Parameters

    • handler: function | null

    Returns void

onKeyDown

  • onKeyDown(keyCode: number, handler: Function): void
  • Sets handler for keyboard key down.

    Parameters

    • keyCode: number
    • handler: Function

    Returns void

onMouseDown

  • onMouseDown(keyCode: number, handler: Function): void
  • Sets handler for mouse key down.

    Parameters

    • keyCode: number
    • handler: Function

    Returns void

onMouseMove

  • onMouseMove(handler: function): void
  • Sets handler for mouse moving.

    Parameters

    • handler: function
        • (this: HTMLDivElement, ev: MouseEvent): any
        • Parameters

          • this: HTMLDivElement
          • ev: MouseEvent

          Returns any

    Returns void

onMouseUp

  • onMouseUp(keyCode: number, handler: Function): void
  • Sets handler for mouse key down.

    Parameters

    • keyCode: number
    • handler: Function

    Returns void

rebindDefaultBrowserActions

  • rebindDefaultBrowserActions(bool: boolean): void
  • Rebind default browser shortcut actions. Will switch rebind option.

    default

    true

    Parameters

    • bool: boolean

      switch to

    Returns void

setControlFunction

  • setControlFunction(func: Function): void

setSensitivity

  • setSensitivity(sensitivity: number): void
  • Set sensitivity for mouse movement

    default

    1

    Parameters

    • sensitivity: number

    Returns void

Generated using TypeDoc