Documentation ¶
Overview ¶
Package blockly wraps google's blocky javascript api for use with gopherjs. see also: https://developers.google.com/blockly https://github.com/gopherjs/gopherjs
Index ¶
- type Block
- func (b *Block) AppendDummyInput(name string) (ret block.Input)
- func (b *Block) AppendStatementInput(name string) (ret block.Input)
- func (b *Block) AppendValueInput(name string) (ret block.Input)
- func (b *Block) BlockId() string
- func (b *Block) BlockType() string
- func (b *Block) BlockWorkspace() block.Workspace
- func (b *Block) Dispose()
- func (b *Block) GetColour() string
- func (b *Block) GetField(name string) (ret *Field)
- func (b *Block) GetFlag(flag block.Flag) bool
- func (b *Block) GetInputsInline() bool
- func (b *Block) GetParent() (ret *Block)
- func (b *Block) GetRootBlock() (ret *Block)
- func (b *Block) HasWorkspace() bool
- func (b *Block) InitSvg()
- func (b *Block) Input(i int) block.Input
- func (b *Block) InputByName(str string) (retInput block.Input, retIndex int)
- func (b *Block) Interpolate(msg string, args []block.Dict)
- func (b *Block) JsonInit(opt block.Dict)
- func (b *Block) NextConnection() block.Connection
- func (b *Block) NumInputs() int
- func (b *Block) OutputConnection() block.Connection
- func (b *Block) PreviousConnection() block.Connection
- func (b *Block) RemoveInput(name string)
- func (b *Block) SetColour(colour string)
- func (b *Block) SetFlag(flag block.Flag, state bool)
- func (b *Block) SetHelpUrl(url string)
- func (b *Block) SetInput(i int, in block.Input)
- func (b *Block) SetInputsInline(yes bool) (err error)
- func (b *Block) SetTooltip(text string)
- func (b *Block) Unplug(healStack bool)
- type BlockChange
- type BlockCreate
- type BlockDelete
- type BlockMove
- type Blockly
- type Callback
- type CommentChange
- type CommentCreate
- type CommentDelete
- type CommentMove
- type Connection
- func (c *Connection) Connect(o block.Connection)
- func (c *Connection) Disconnect()
- func (c *Connection) IsConnected() bool
- func (c *Connection) IsConnectionAllowed() bool
- func (c *Connection) IsSuperior() bool
- func (c *Connection) SourceBlock() (ret block.Shape)
- func (c *Connection) String() string
- func (c *Connection) TargetBlock() (ret block.Shape)
- func (c *Connection) TargetConnection() block.Connection
- type Event
- type EventId
- type Extensions
- type Field
- type FieldAngle
- type FieldCheckbox
- type FieldColour
- type FieldDropdown
- type FieldImage
- type FieldImageDropdown
- type FieldLabel
- type FieldNumber
- type FieldText
- type FieldVariable
- type Fields
- type Globals
- func (p *Globals) GenerateUniqueName() (ret string)
- func (p *Globals) IsBlockRegistered(blockType string) (ret bool)
- func (p *Globals) NewBlankWorkspace(isMutator bool) (ret *Workspace)
- func (p *Globals) NewWorkspace(elementId, mediaPath string, tools interface{}) *Workspace
- func (p *Globals) RegisterBlock(blockType string, desc block.Dict) (err error)
- func (p *Globals) RegisterMutator(name string, m block.Mutator) (err error)
- type Input
- func (in *Input) AppendField(f *Field)
- func (in *Input) AppendNamedField(name string, f *Field)
- func (in *Input) Block() *Block
- func (in *Input) Connection() block.Connection
- func (in *Input) Dispose()
- func (in *Input) Fields() (ret *Fields)
- func (in *Input) InputName() string
- func (in *Input) InputType() string
- func (in *Input) IsVisible() bool
- func (in *Input) SetAlign(a InputAlign)
- func (in *Input) SetCheck(compatibleType string) (err error)
- func (in *Input) SetChecks(compatibleTypes []string) (err error)
- func (in *Input) SetInvisible()
- func (in *Input) SetVisible(visible bool)
- type InputAlign
- type InputType
- type Mixin
- type Size
- type ToolboxPosition
- type UiChange
- type Utils
- type VarCreate
- type VarDelete
- type VarRename
- type Workspace
- func (ws *Workspace) AddChangeListener(fn func(evt interface{})) *js.Object
- func (ws *Workspace) Clear()
- func (ws *Workspace) ClearUndo()
- func (ws *Workspace) Dispose()
- func (ws *Workspace) GetBlockById(id string) (ret *Block)
- func (ws *Workspace) NewBlock(blockType string) (block.Shape, error)
- func (ws *Workspace) NewBlockWithId(blockId string, blockType string) (ret block.Shape, err error)
- func (ws *Workspace) OnDelete(onDel block.OnDelete)
- func (ws *Workspace) RemoveChangeListener(wrappedFn *js.Object)
- func (ws *Workspace) WorkspaceId() string
- type Xml
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Block ¶
type Block struct { *js.Object // Blockly.Block Id string `js:"id"` Type string `js:"type"` Tooltip string `js:"tooltip"` ContextMenu bool `js:"contextMenu"` Comment string `js:"comment"` IsInFlyout bool `js:"isInFlyout"` IsInMutator bool `js:"isInMutator"` Rtl bool `js:"RTL"` InputsInline bool `js:"inputsInline"` // contains filtered or unexported fields }
func (*Block) AppendDummyInput ¶
AppendDummyInput for standalone fields.
func (*Block) AppendStatementInput ¶
AppendStatementInput for blocks with previous statements. statements give a c-shape; they are slices
func (*Block) AppendValueInput ¶
AppendValueInput for blocks with output.
func (*Block) BlockWorkspace ¶
func (*Block) Dispose ¶
func (b *Block) Dispose()
Dispose removes the block from the workspace. To prevent child blocks from *also* being disposed, Unplug() the block first.
func (*Block) GetInputsInline ¶
func (*Block) GetParent ¶
func (b* Block)lastConnectionInStack () { b.Call("lastConnectionInStack") }
func (*Block) GetRootBlock ¶
func (*Block) HasWorkspace ¶
func (*Block) InitSvg ¶
func (b *Block) InitSvg()
feels like this should have been asynchronous, hidden so that its called after initialiation automatically rather than the caller/creator deciding when its a good time. [ it gets littered after NewBlock() and is illegal in "headless" builds ]
func (*Block) InputByName ¶
func (*Block) Interpolate ¶
func (b* Block)mixin (mixinObj, optDisableCheck) { b.Call("mixin") }
func (*Block) NextConnection ¶
func (b *Block) NextConnection() block.Connection
connection to a piece in the following line
func (*Block) OutputConnection ¶
func (b *Block) OutputConnection() block.Connection
left side puzzle connector
func (*Block) PreviousConnection ¶
func (b *Block) PreviousConnection() block.Connection
connection to a piece in the preceeding line
func (*Block) RemoveInput ¶
func (*Block) SetHelpUrl ¶
func (b* Block)setConnectionsHidden (hidden) { b.Call("setConnectionsHidden") } func (b* Block)getMatchingConnection (otherBlock, conn) { b.Call("getMatchingConnection") }
func (*Block) SetInputsInline ¶
func (b* Block)setPreviousStatement (newBoolean, optCheck) { b.Call("setPreviousStatement") } func (b* Block)setNextStatement (newBoolean, optCheck) { b.Call("setNextStatement") } func (b* Block)setOutput (newBoolean, optCheck) { b.Call("setOutput") }
func (*Block) SetTooltip ¶
type BlockChange ¶
type BlockChange struct { *Event // Element events include: // collapsed - .collapsed status changed ( via setCollapsed ) // comment - comment text changed ( via setCommentText ) // disabled - disabled status changed ( via setDisabled ) // field - when checkbox, colour, dropdown, text input, variable, etc. ( via setValue ) // inline - inputs inline changed ( via setInputsInline ) // mutation - "a procedure definition changes its parameters". or workspaceChanged, -- via Blockly.Procedures.mutatateCallers. Element string `js:"element"` // Name of element affected Name string `js:"name"` OldValue *js.Object `js:"oldValue"` NewValue *js.Object `js:"newValue"` }
BlockChange -- when the status of a block has changed. ( note, changes to inputs are reported by BlockMove. )
type BlockCreate ¶
type BlockCreate struct { *Event // xml *js.Object An XML tree defining the new block and any connected child blocks. Ids *js.Object `js:"ids"` // An array containing the UUIDs of the new block and any connected child blocks. }
triggered after the block has been added to the workspace; the block object can be found via the event's blockId
type BlockDelete ¶
type BlockMove ¶
type BlockMove struct {
*Event
}
BlockMove -- event when a block has been dragged/dropped into a new slot. for why this uses methods instead of properties see https://github.com/gopherjs/gopherjs/issues/617
func (*BlockMove) NextInputName ¶
NextInputName - Input in new parent ( if any ). Empty if it's the parent's next block.
func (*BlockMove) NextParentId ¶
NextParentId - UUID of new parent block. Empty if it is a top level block.
func (*BlockMove) PrevInputName ¶
PrevInputName - Input in old parent ( if any ). Empty if it's the parent's next block.
func (*BlockMove) PrevParentId ¶
PrevParentId - UUID of old parent block. Empty if it was a top level block.
type CommentChange ¶
type CommentChange struct {
*Event
}
type CommentCreate ¶
type CommentCreate struct {
*Event
}
type CommentDelete ¶
type CommentDelete struct {
*Event
}
type CommentMove ¶
type CommentMove struct {
*Event
}
type Connection ¶
type Connection struct { *js.Object Type InputType `js:"type"` // contains filtered or unexported fields }
Connection *potentially* connects to another block; it's more a "connector" than an "connection".
func (*Connection) Connect ¶
func (c *Connection) Connect(o block.Connection)
func (*Connection) Disconnect ¶
func (c *Connection) Disconnect()
func (*Connection) IsConnected ¶
func (c *Connection) IsConnected() bool
func (*Connection) IsConnectionAllowed ¶
func (c *Connection) IsConnectionAllowed() bool
func (*Connection) IsSuperior ¶
func (c *Connection) IsSuperior() bool
func (*Connection) SourceBlock ¶
func (c *Connection) SourceBlock() (ret block.Shape)
func (*Connection) String ¶
func (c *Connection) String() string
func (*Connection) TargetBlock ¶
func (c *Connection) TargetBlock() (ret block.Shape)
func (*Connection) TargetConnection ¶
func (c *Connection) TargetConnection() block.Connection
type Event ¶
type Event struct { *js.Object // Blockly.Events.Abstract; Type EventId `js:"type"` BlockId string `js:"blockId"` WorkspaceId string `js:"workspaceId"` Group string `js:"group"` RecordUndo bool `js:"recordUndo"` }
Event -- on the blockly side, events are raised with Blockly.Events.fire. there is no node "hierarchy" -- all listeners get all events.
type Extensions ¶
func (*Extensions) Register ¶
func (x *Extensions) Register(name string, cb Callback)
func (*Extensions) RegisterMixin ¶
func (x *Extensions) RegisterMixin(name string, mixin Mixin)
func (*Extensions) RegisterMutator ¶
type Field ¶
func (*Field) GetSize ¶
func (f *Field) setSourceBlock (block) { func (f *Field) init () { func (f *Field) initModel () { func (f *Field) dispose () { func (f *Field) updateEditable () { func (f *Field) isCurrentlyEditable () { func (f *Field) isVisible () { func (f *Field) setVisible (visible) { func (f *Field) setValidator (handler) { func (f *Field) getValidator () { func (f *Field) classValidator (text) { func (f *Field) callValidator (text) { func (f *Field) getSvgRoot () { func (f *Field) updateWidth () {
func (*Field) SetTooltip ¶
in blockly newTip can be an element as well
type FieldAngle ¶
type FieldAngle float32
type FieldCheckbox ¶
type FieldCheckbox bool
type FieldColour ¶
type FieldColour string //'#rrggbb'
type FieldImage ¶
type FieldImageDropdown ¶
type FieldImageDropdown []FieldImage
type FieldLabel ¶
type FieldLabel struct { *Field // contains filtered or unexported fields }
type FieldNumber ¶
type FieldNumber float32
type FieldText ¶
type FieldText string // field_input, FieldTextInput; pre-existing validators inclde numberValidator, nongenativeIntegerValidator
type FieldVariable ¶
type FieldVariable string
type Globals ¶
type Globals struct { Blockly *Blockly Extensions *Extensions Xml *Xml Utils *Utils }
implements block.Project
func (*Globals) GenerateUniqueName ¶
func (*Globals) IsBlockRegistered ¶
func (*Globals) NewBlankWorkspace ¶
func (*Globals) NewWorkspace ¶
note: toolbox can be an xml string containing the toolbox
func (*Globals) RegisterBlock ¶
type Input ¶
type Input struct { *js.Object // Blockly.Input Type InputType `js:"type"` Name string `js:"name"` Align InputAlign `js:"align"` // contains filtered or unexported fields }
func (*Input) AppendField ¶
blockly's append field allows field to be a string, and then to pass an optional name see also: insertFieldAt
func (*Input) AppendNamedField ¶
func (*Input) Connection ¶
func (in *Input) Connection() block.Connection
func (*Input) SetAlign ¶
func (in *Input) SetAlign(a InputAlign)
func (*Input) SetInvisible ¶
func (in *Input) SetInvisible()
func (*Input) SetVisible ¶
type InputAlign ¶
type InputAlign int
const ( AlignLeft InputAlign = iota - 1 AlignCentre AlignRight )
func (InputAlign) String ¶
func (i InputAlign) String() string
type ToolboxPosition ¶
type ToolboxPosition int
const ( ToolboxAtTop ToolboxPosition = iota ToolboxAtBottom ToolboxAtLeft ToolboxAtRight )
type UiChange ¶
type UiChange struct { *Event Element string `js:"element"` OldValue *js.Object `js:"oldValue"` NewValue *js.Object `js:"newValue"` }
ex. warningOpen ( showing or hding the warning bubble ), mutatorOpen, commentOpen, (block) click, (block) selected.
type Workspace ¶
type Workspace struct { *js.Object Id string `js:"id"` Options *js.Object `js:"options"` Rtl bool `js:"RTL"` HorizontalLayout bool `js:"horizontalLayout"` ToolboxPosition ToolboxPosition `js:"toolboxPosition"` Rendered bool `js:"rendered"` IsClearing bool `js:"isClearing"` IsMutator bool `js:"isMutator"` // from workspacesvg // contains filtered or unexported fields }
Workspace - a container for Blockly blocks. The mutation popups, and the main editing space are examples of separate workspaces. ( The toolbox uses the main workspace. )
func (*Workspace) AddChangeListener ¶
func (ws* Workspace) remainingCapacity () { return ws.Call("remainingCapacity") }
func (ws* Workspace) undo (redo) { return ws.Call("undo") }
func (ws* Workspace) clearUndo () { return ws.Call("clearUndo") }
func (*Workspace) Clear ¶
func (ws *Workspace) Clear()
func (ws* Workspace) getCommentById (id) { return ws.Call("getCommentById") }
func (ws* Workspace) allInputsFilled = function(
func (ws* Workspace) getPotentialVariableMap () { return ws.Call("getPotentialVariableMap") }
func (ws* Workspace) createPotentialVariableMap () { return ws.Call("createPotentialVariableMap") }
func (ws* Workspace) getVariableMap () { return ws.Call("getVariableMap") }
func (*Workspace) GetBlockById ¶
GetBlockById lookup ( and wrap ) a blockly block for use with go apis.
func (*Workspace) NewBlockWithId ¶
func (*Workspace) RemoveChangeListener ¶
func (*Workspace) WorkspaceId ¶
type Xml ¶
via Blockly.Xml
func (*Xml) DomToBlock ¶
func (x *Xml) clearWorkspaceAndLoadFromXml (xml, workspace) { func (x *Xml) domToWorkspace (xml, workspace) { func (x *Xml) appendDomToWorkspace (xml, workspace) {
func (*Xml) DomToText ¶
func (x *Xml) workspaceToDom() (workspace, OptNoId) { func (x *Xml) variablesToDom (variableList) { func (x *Xml) blockToDomWithXY (block, OptNoId) { func (x *Xml) fieldToDomVariable_ (field) { func (x *Xml) fieldToDom_ (field) { func (x *Xml) allFieldsToDom_ (block, element) { func (x *Xml) blockToDom (block, OptNoId) { func (x *Xml) cloneShadow_ (shadow) {