Skip to content

Events

The events module provides a convenient way to emit commonly needed events

Predefined events

  • LEFT_MOUSE_CLICK
  • LEFT_MOUSE_DOWN
  • LEFT_MOUSE_UP
  • MOUSE_DOUBLE_CLICK
  • RIGHT_MOUSE_CLICK
  • RIGHT_MOUSE_DOWN
  • RIGHT_MOUSE_UP
  • KEY_PRESS
  • KEY_DOWN
  • KEY_UP
  • FOCUS - indicates focus was gained
  • BLUR - indicates loss of focus
  • CHANGE - indicates an input value was changed (mostly relevant to web apps)

The event constants are used like this

javascript
var field = new Field('**/the-button');

// Trigger a button's click listener directly
field.emit(Events.LEFT_MOUSE_CLICK);

// A key event
field.emit(Events.KEY_DOWN, 'Enter');

There are more event emitting examples in the Emit api section.