Constructor

Gesture

new Gesture(e, creatorWorkspace)

Class for one gesture.

Parameter

e

Event

The event that kicked off this gesture.

Value must not be null.

creatorWorkspace

Blockly.WorkspaceSvg

The workspace that created this gesture and has a reference to it.

Value must not be null.

Properties

isEnding_

protected

boolean

Boolean used internally to break a cycle in disposal.

mouseDownXY_

goog.math.Coordinate

The position of the mouse when the gesture started. Units are css pixels, with (0, 0) at the top left of the browser window (mouseEvent clientX/Y).

onMoveWrapper_

protected

Array of non-null Array

A handle to use to unbind a mouse move listener at the end of a drag. Opaque data returned from Blockly.bindEventWithChecks_.

onUpWrapper_

protected

Array of non-null Array

A handle to use to unbind a mouse up listener at the end of a drag. Opaque data returned from Blockly.bindEventWithChecks_.

startWorkspace_

protected

Blockly.WorkspaceSvg

The workspace that the gesture started on. There may be multiple workspaces on a page; this is more accurate than using Blockly.getMainWorkspace().

Methods

inProgress

static

inProgress() returns boolean

Is a drag or other gesture currently in progress on any workspace?

Returns

boolean True if gesture is occurring.

bindMouseEvents

package

bindMouseEvents(e)

Bind gesture events.

Parameter

e

Event

A mouse down or touch start event.

Value must not be null.

cancel

package

cancel()

Cancel an in-progress gesture. If a workspace or block drag is in progress, end the drag at the most recent location.

dispose

package

dispose()

Sever all links from this object.

doStart

package

doStart(e)

Start a gesture: update the workspace to indicate that a gesture is in progress and bind mousemove and mouseup handlers.

Parameter

e

Event

A mouse down or touch start event.

Value must not be null.

getInsertionMarkers

package

getInsertionMarkers() returns Array of non-null Blockly.BlockSvg

Get a list of the insertion markers that currently exist. Block drags have 0, 1, or 2 insertion markers.

Returns

non-null Array of non-null Blockly.BlockSvg A possibly empty list of insertion marker blocks.

handleBlockStart

package

handleBlockStart(e, block)

Handle a mousedown/touchstart event on a block.

Parameter

e

Event

A mouse down or touch start event.

Value must not be null.

block

Blockly.BlockSvg

The block the event hit.

Value must not be null.

handleBubbleStart

package

handleBubbleStart(e, bubble)

Handle a mousedown/touchstart event on a bubble.

Parameter

e

Event

A mouse down or touch start event.

Value must not be null.

bubble

Blockly.Bubble

The bubble the event hit.

Value must not be null.

handleFlyoutStart

package

handleFlyoutStart(e, flyout)

Handle a mousedown/touchstart event on a flyout.

Parameter

e

Event

A mouse down or touch start event.

Value must not be null.

flyout

Blockly.Flyout

The flyout the event hit.

Value must not be null.

handleMove

package

handleMove(e)

Handle a mouse move or touch move event.

Parameter

e

Event

A mouse move or touch move event.

Value must not be null.

handleRightClick

package

handleRightClick(e)

Handle a real or faked right-click event by showing a context menu.

Parameter

e

Event

A mouse move or touch move event.

Value must not be null.

handleUp

package

handleUp(e)

Handle a mouse up or touch end event.

Parameter

e

Event

A mouse up or touch end event.

Value must not be null.

handleWsStart

package

handleWsStart(e, ws)

Handle a mousedown/touchstart event on a workspace.

Parameter

e

Event

A mouse down or touch start event.

Value must not be null.

ws

Blockly.Workspace

The workspace the event hit.

Value must not be null.

hasStarted

package

hasStarted() returns boolean

Whether this gesture has already been started. In theory every mouse down has a corresponding mouse up, but in reality it is possible to lose a mouse up, leaving an in-process gesture hanging.

Returns

boolean Whether this gesture was a click on a workspace.

isDragging

package

isDragging() returns boolean

Whether this gesture is a drag of either a workspace or block. This function is called externally to block actions that cannot be taken mid-drag (e.g. using the keyboard to delete the selected blocks).

Returns

boolean True if this gesture is a drag of a workspace or block.

setStartBlock

package

setStartBlock(block)

Record the block that a gesture started on, and set the target block appropriately.

Parameter

block

Blockly.BlockSvg

The block the gesture started on.

setStartBubble

package

setStartBubble(bubble)

Record the bubble that a gesture started on

Parameter

bubble

Blockly.Bubble

The bubble the gesture started on.

setStartField

package

setStartField(field)

Record the field that a gesture started on.

Parameter

field

Blockly.Field

The field the gesture started on.