Class: cuiDraggable

cuiDraggable

Draggables can be translated by dragging.

new cuiDraggable()

Create a new cuiDraggable.
Source:

Members

<static> isPointerDown :boolean

Flag specifying whether a mouse button or finger is pushing the object or has been pushing the object and is still held down (but may have moved outside the object's rectangle).
Type:
  • boolean
Source:

<static> isPointerInside :boolean

Flag specifying whether a mouse button or finger is inside the object's rectangle.
Type:
  • boolean
Source:

<static> translationX :number

Difference in x coordinate by which the centre of the draggable has been moved relative to its initial position (specified by x + 0.5 * width with the arguments of cuiDraggable#process).
Type:
  • number
Source:

<static> translationY :number

Difference in y coordinate by which the centre of the draggable has been moved relative to its initial position (specified by y + 0.5 * height with the arguments of cuiDraggable#process).
Type:
  • number
Source:

Methods

isClicked() → {boolean}

Determine whether the draggable has just been clicked.
Source:
Returns:
True if the draggable has been clicked, false otherwise.
Type
boolean

isDoubleClicked() → {boolean}

Determine whether the draggable has just been double clicked.
Source:
Returns:
True if the button has been double clicked, false otherwise.
Type
boolean

isHeldDown() → {boolean}

Determine whether the pointer has just been held down longer than cuiTimeUntilHold.
Source:
Returns:
True if the pointer has just been held down long enough, false otherwise.
Type
boolean

process(event, x, y, width, height, text, imageNormal, imageFocused, imagePressed, interactionBits) → {boolean}

Either process the event (if event != null) and return true if the event has been processed, or draw the appropriate image for the object state in the rectangle with a text string on top of it (if event == null) and return false. This function is usually called by cuiPage.process of a cuiPage.
Parameters:
Name Type Description
event Object An object describing a user event by its "type", coordinates in page coordinates ("eventX" and "eventY"), an "identifier" for touch events, and optionally "buttons" to specify which mouse buttons are depressed. If null, the function should redraw the object.
x number The x coordinate of the top, left corner of the object's rectangle.
y number The y coordinate of the top, left corner of the object's rectangle.
width number The width of the object's rectangle.
height number The height of the object's rectangle.
text string A text that is written at the center of the rectangle. (May be null).
imageNormal Object An image to be drawn inside the object's rectangle if there are no user interactions. (May be null.)
imageFocused Object An image to be drawn inside the object's rectangle if the mouse hovers over the object's rectangle or a touch point moves into it. (May be null.)
imagePressed Object An image to be drawn inside the object's rectangle if a mouse button is pushed or the object is touched. (May be null.)
interactionBits number The forms of interaction, either cuiConstants.none or a bitwise-or of other constants in cuiConstants, e.g. cuiConstants.isDraggableWithOneFinger | cuiConstants.isLimitedToHorizontalDragging.
Source:
Returns:
True if event != null and the event has been processed (implying that no other GUI elements should process it). False otherwise.
Type
boolean