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.

Property

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).

Methods

bindMouseEvents

bindMouseEvents(e)

Bind gesture events.

Parameter

e

Event

A mouse down or touch start event.

Value must not be null.

cancel

cancel()

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

dispose

dispose()

Sever all links from this object.

doStart

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.

handleBlockStart

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

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

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

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

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

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

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

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

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

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

setStartBubble(bubble)

Record the bubble that a gesture started on

Parameter

bubble

Blockly.Bubble

The bubble the gesture started on.

setStartField

setStartField(field)

Record the field that a gesture started on.

Parameter

field

Blockly.Field

The field the gesture started on.