Classes

Namespaces

Enumeration

KeyCodes

static

number

Key codes for common characters.

Copied from Closure's goog.events.KeyCodes

This list is not localized and therefore some of the key codes are not correct for non US keyboard layouts. See comments below.

Value

WIN_KEY_FF_LINUX

MAC_ENTER

BACKSPACE

TAB

NUM_CENTER

ENTER

SHIFT

CTRL

ALT

PAUSE

CAPS_LOCK

ESC

SPACE

PAGE_UP

PAGE_DOWN

END

HOME

LEFT

UP

RIGHT

DOWN

PLUS_SIGN

PRINT_SCREEN

INSERT

DELETE

ZERO

ONE

TWO

THREE

FOUR

FIVE

SIX

SEVEN

EIGHT

NINE

FF_SEMICOLON

FF_EQUALS

FF_DASH

FF_HASH

QUESTION_MARK

AT_SIGN

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

META

WIN_KEY_RIGHT

CONTEXT_MENU

NUM_ZERO

NUM_ONE

NUM_TWO

NUM_THREE

NUM_FOUR

NUM_FIVE

NUM_SIX

NUM_SEVEN

NUM_EIGHT

NUM_NINE

NUM_MULTIPLY

NUM_PLUS

NUM_MINUS

NUM_PERIOD

NUM_DIVISION

F1

F2

F3

F4

F5

F6

F7

F8

F9

F10

F11

F12

NUMLOCK

SCROLL_LOCK

FIRST_MEDIA_KEY

LAST_MEDIA_KEY

SEMICOLON

DASH

EQUALS

COMMA

PERIOD

SLASH

APOSTROPHE

TILDE

SINGLE_QUOTE

OPEN_SQUARE_BRACKET

BACKSLASH

CLOSE_SQUARE_BRACKET

WIN_KEY

MAC_FF_META

MAC_WK_CMD_LEFT

MAC_WK_CMD_RIGHT

WIN_IME

VK_NONAME

PHANTOM

Properties

global

static

Reference to the global object.

More info on this implementation here: https://docs.google.com/document/d/1NAeW4Wk7I7FV0Y2tcUFvQdGMc89k2vdgSXInw8_nvCI/edit

KeyCodes

static

number

Key codes for common characters.

Copied from Closure's goog.events.KeyCodes

This list is not localized and therefore some of the key codes are not correct for non US keyboard layouts. See comments below.

Value

WIN_KEY_FF_LINUX

MAC_ENTER

BACKSPACE

TAB

NUM_CENTER

ENTER

SHIFT

CTRL

ALT

PAUSE

CAPS_LOCK

ESC

SPACE

PAGE_UP

PAGE_DOWN

END

HOME

LEFT

UP

RIGHT

DOWN

PLUS_SIGN

PRINT_SCREEN

INSERT

DELETE

ZERO

ONE

TWO

THREE

FOUR

FIVE

SIX

SEVEN

EIGHT

NINE

FF_SEMICOLON

FF_EQUALS

FF_DASH

FF_HASH

QUESTION_MARK

AT_SIGN

A

B

C

D

E

F

G

H

I

J

K

L

M

N

O

P

Q

R

S

T

U

V

W

X

Y

Z

META

WIN_KEY_RIGHT

CONTEXT_MENU

NUM_ZERO

NUM_ONE

NUM_TWO

NUM_THREE

NUM_FOUR

NUM_FIVE

NUM_SIX

NUM_SEVEN

NUM_EIGHT

NUM_NINE

NUM_MULTIPLY

NUM_PLUS

NUM_MINUS

NUM_PERIOD

NUM_DIVISION

F1

F2

F3

F4

F5

F6

F7

F8

F9

F10

F11

F12

NUMLOCK

SCROLL_LOCK

FIRST_MEDIA_KEY

LAST_MEDIA_KEY

SEMICOLON

DASH

EQUALS

COMMA

PERIOD

SLASH

APOSTROPHE

TILDE

SINGLE_QUOTE

OPEN_SQUARE_BRACKET

BACKSLASH

CLOSE_SQUARE_BRACKET

WIN_KEY

MAC_FF_META

MAC_WK_CMD_LEFT

MAC_WK_CMD_RIGHT

WIN_IME

VK_NONAME

PHANTOM

Methods

arrayRemove

package   static

arrayRemove(arr, obj) returns boolean

Removes the first occurrence of a particular value from an array.

Parameter

arr

Array

Array from which to remove value.

Value must not be null.

obj

any type

Object to remove.

Returns

boolean True if an element was removed.

checkMessageReferences

static

checkMessageReferences(message) returns boolean

Validates that any %{MSG_KEY} references in the message refer to keys of the Blockly.Msg string table.

Parameter

message

string

Text which might contain string table references.

Returns

boolean True if all message references have matching values. Otherwise, false.

genUid

static

genUid() returns string

Generate a unique ID. This should be globally unique. 87 characters ^ 20 length > 128 bits (better than a UUID).

Returns

string A globally unique ID string.

getBlockTypeCounts

static

getBlockTypeCounts(block, opt_stripFollowing) returns Object

Get a map of all the block's descendants mapping their type to the number of children with that type.

Parameter

block

Blockly.Block

The block to map.

Value must not be null.

opt_stripFollowing

Optional

boolean

Optionally ignore all following statements (blocks that are not inside a value or statement input of the block).

Returns

non-null Object Map of types to type counts for descendants of the bock.

getDocumentScroll

static

getDocumentScroll() returns Blockly.utils.Coordinate

Gets the document scroll distance as a coordinate object. Copied from Closure's goog.dom.getDocumentScroll.

Returns

non-null Blockly.utils.Coordinate Object with values 'x' and 'y'.

getInjectionDivXY_

static

getInjectionDivXY_(element) returns Blockly.utils.Coordinate

Return the coordinates of the top-left corner of this element relative to the div Blockly was injected into.

Parameter

element

Element

SVG element to find the coordinates of. If this is not a child of the div Blockly was injected into, the behaviour is undefined.

Value must not be null.

Returns

non-null Blockly.utils.Coordinate Object with .x and .y properties.

getRelativeXY

static

getRelativeXY(element) returns Blockly.utils.Coordinate

Return the coordinates of the top-left corner of this element relative to its parent. Only for SVG elements and children (e.g. rect, g, path).

Parameter

element

Element

SVG element to find the coordinates of.

Value must not be null.

Returns

non-null Blockly.utils.Coordinate Object with .x and .y properties.

getScrollDeltaPixels

static

getScrollDeltaPixels(e) returns Object

Get the scroll delta of a mouse event in pixel units.

Parameter

e

Event

Mouse event.

Value must not be null.

Returns

{x: number, y: number} Scroll delta object with .x and .y properties.

getViewportBBox

package   static

getViewportBBox() returns Object

Get the position of the current viewport in window coordinates. This takes scroll into account.

Returns

non-null Object An object containing window width, height, and scroll position in window coordinates.

is3dSupported

static

is3dSupported() returns boolean

Check if 3D transforms are supported by adding an element and attempting to set the property.

Returns

boolean True if 3D transforms are supported.

isRightButton

static

isRightButton(e) returns boolean

Is this event a right-click?

Parameter

e

Event

Mouse event.

Value must not be null.

Returns

boolean True if right-click.

isTargetInput

static

isTargetInput(e) returns boolean

Is this event targeting a text input widget?

Parameter

e

Event

An event.

Value must not be null.

Returns

boolean True if text input.

mouseToSvg

static

mouseToSvg(e, svg, matrix) returns SVGPoint

Return the converted coordinates of the given mouse event. The origin (0,0) is the top-left corner of the Blockly SVG.

Parameter

e

Event

Mouse event.

Value must not be null.

svg

Element

SVG element.

Value must not be null.

matrix

SVGMatrix

Inverted screen CTM to use.

Returns

non-null SVGPoint Object with .x and .y properties.

noEvent

static

noEvent(e)

Don't do anything for this event, just halt propagation.

Parameter

e

Event

An event.

Value must not be null.

replaceMessageReferences

static

replaceMessageReferences(message) returns string

Replaces string table references in a message, if the message is a string. For example, "%{bky_my_msg}" and "%{BKY_MY_MSG}" will both be replaced with the value in Blockly.Msg['MY_MSG'].

Parameter

message

(string or unknown)

Message, which may be a string that contains string table references.

Returns

string String with message references replaced.

runAfterPageLoad

static

runAfterPageLoad(fn)

Calls a function after the page has loaded, possibly immediately.

Parameter

fn

function()

Function to run.

Throws

Error Will throw if no global document can be found (e.g., Node.js).

screenToWsCoordinates

package   static

screenToWsCoordinates(ws, screenCoordinates) returns Blockly.utils.Coordinate

Converts screen coordinates to workspace coordinates.

Parameter

ws

Blockly.WorkspaceSvg

The workspace to find the coordinates on.

screenCoordinates

Blockly.utils.Coordinate

The screen coordinates to be converted to workspace coordintaes

Returns

Blockly.utils.Coordinate The workspace coordinates.

tokenizeInterpolation

static

tokenizeInterpolation(message) returns Array of (string or number)

Parse a string with any number of interpolation tokens (%1, %2, ...). It will also replace string table references (e.g., %{bky_my_msg} and %{BKY_MY_MSG} will both be replaced with the value in Blockly.Msg['MY_MSG']). Percentage sign characters '%' may be self-escaped (e.g., '%%').

Parameter

message

string

Text which might contain string table references and interpolation tokens.

Returns

non-null Array of (string or number) Array of strings and numbers.