onDragEvents([callback], [remove])

Class: Button. Method inherited from UIComponent.

Description:

Gets, registers or unregisters a handler function for drag related events. Call without parameters to get an array of already registered handler functions.

Parameters:

Name Type Default Description

[callback]

function

The event handler function that receives a DragEvent object. Pass null to unregister all handler functions.

[remove]

boolean

false

Set to true to unregister the event handler.

Returns:

An array of handler functions if no arguments are passed, otherwise this component for method chaining.

Type: this | Array.<function()>

Examples:

// Example event object:
const e = {
  target: object,         // The component that triggered the event.
  type: string,           // `dragstart`, `dragend`, `cancel`.
  action: string          // One of DragDropAction enum values. Present when applicable.
  x: number,              // X position of a pointer relative to this component. Present when e.type is `dragstart` or `dragend`.
  y: number,              // Y position of a pointer relative to this component. Present when e.type is `dragstart` or `dragend`.
  screenX: number,        // X position of a pointer relative to default screen. Present when e.type is `dragstart` or `dragend`.
  screenY: number,        // Y position of a pointer relative to default screen. Present when e.type is `dragstart` or `dragend`.
  button: number,         // Indicates a pointing device button involved in dragging. Value of MouseButton enum.
  modifiers: number,      // Keyboard modifiers (bitmask or flags). Present when e.type is `dragstart`.
  modifiersText: string,  // Keyboard modifiers. Present when e.type is `dragstart`.
  alt: boolean,           // Indicates if ALT key was pressed. Present when e.type is `dragstart`.
  shift: boolean,         // Indicates if SHIFT key was pressed. Present when e.type is `dragstart`.
  ctrl: boolean,          // Indicates if CTRL key was pressed. Present when e.type is `dragstart`.
  selected: number[]      // Array of selected indexes of a List component whose items are being dragged. Present when List items are being dragged.
};

Also See: