diff --git a/blocks/procedures.js b/blocks/procedures.js index d545a1437..223a655cd 100644 --- a/blocks/procedures.js +++ b/blocks/procedures.js @@ -687,7 +687,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { // Block is deleted or is in a flyout. return; } - if (event.type == Blockly.Events.CREATE && + if (event.type == Blockly.Events.BLOCK_CREATE && event.ids.indexOf(this.id) != -1) { // Look for the case where a procedure call was created (usually through // paste) and there is no matching definition. In this case, create @@ -730,7 +730,7 @@ Blockly.Blocks['procedures_callnoreturn'] = { Blockly.Xml.domToWorkspace(xml, this.workspace); Blockly.Events.setGroup(false); } - } else if (event.type == Blockly.Events.DELETE) { + } else if (event.type == Blockly.Events.BLOCK_DELETE) { // Look for the case where a procedure definition has been deleted, // leaving this block (a procedure call) orphaned. In this case, delete // the orphan. diff --git a/core/block.js b/core/block.js index 76c94b3e9..da77fe135 100644 --- a/core/block.js +++ b/core/block.js @@ -156,7 +156,7 @@ Blockly.Block = function(workspace, prototypeName, opt_id) { /** @type {boolean|undefined} */ this.inputsInlineDefault = this.inputsInline; if (Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Create(this)); + Blockly.Events.fire(new Blockly.Events.BlockCreate(this)); } // Bind an onchange function, if it exists. if (goog.isFunction(this.onchange)) { @@ -209,7 +209,7 @@ Blockly.Block.prototype.dispose = function(healStack) { } this.unplug(healStack); if (Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Delete(this)); + Blockly.Events.fire(new Blockly.Events.BlockDelete(this)); } Blockly.Events.disable(); @@ -793,7 +793,7 @@ Blockly.Block.prototype.setOutput = function(newBoolean, opt_check) { */ Blockly.Block.prototype.setInputsInline = function(newBoolean) { if (this.inputsInline != newBoolean) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this, 'inline', null, this.inputsInline, newBoolean)); this.inputsInline = newBoolean; } @@ -832,7 +832,7 @@ Blockly.Block.prototype.getInputsInline = function() { */ Blockly.Block.prototype.setDisabled = function(disabled) { if (this.disabled != disabled) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this, 'disabled', null, this.disabled, disabled)); this.disabled = disabled; } @@ -869,7 +869,7 @@ Blockly.Block.prototype.isCollapsed = function() { */ Blockly.Block.prototype.setCollapsed = function(collapsed) { if (this.collapsed_ != collapsed) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this, 'collapsed', null, this.collapsed_, collapsed)); this.collapsed_ = collapsed; } @@ -1395,7 +1395,7 @@ Blockly.Block.prototype.getCommentText = function() { */ Blockly.Block.prototype.setCommentText = function(text) { if (this.comment != text) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this, 'comment', null, this.comment, text || '')); this.comment = text; } @@ -1433,7 +1433,7 @@ Blockly.Block.prototype.getRelativeToSurfaceXY = function() { */ Blockly.Block.prototype.moveBy = function(dx, dy) { goog.asserts.assert(!this.parentBlock_, 'Block has parent.'); - var event = new Blockly.Events.Move(this); + var event = new Blockly.Events.BlockMove(this); this.xy_.translate(dx, dy); event.recordNew(); Blockly.Events.fire(event); diff --git a/core/block_dragger.js b/core/block_dragger.js index 03e7ad2f7..0ba1749f0 100644 --- a/core/block_dragger.js +++ b/core/block_dragger.js @@ -234,7 +234,7 @@ Blockly.BlockDragger.prototype.endBlockDrag = function(e, currentDragDeltaXY) { * @private */ Blockly.BlockDragger.prototype.fireMoveEvent_ = function() { - var event = new Blockly.Events.Move(this.draggingBlock_); + var event = new Blockly.Events.BlockMove(this.draggingBlock_); event.oldCoordinate = this.startXY_; event.recordNew(); Blockly.Events.fire(event); diff --git a/core/block_svg.js b/core/block_svg.js index 0aec6f96c..6f44aed45 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -304,7 +304,7 @@ Blockly.BlockSvg.prototype.getRelativeToSurfaceXY = function() { */ Blockly.BlockSvg.prototype.moveBy = function(dx, dy) { goog.asserts.assert(!this.parentBlock_, 'Block has parent.'); - var event = new Blockly.Events.Move(this); + var event = new Blockly.Events.BlockMove(this); var xy = this.getRelativeToSurfaceXY(); this.translate(xy.x + dx, xy.y + dy); this.moveConnections_(dx, dy); diff --git a/core/comment.js b/core/comment.js index dc650738b..f0d5f3537 100644 --- a/core/comment.js +++ b/core/comment.js @@ -119,7 +119,7 @@ Blockly.Comment.prototype.createEditor_ = function() { }); Blockly.bindEventWithChecks_(textarea, 'change', this, function(e) { if (this.text_ != textarea.value) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.block_, 'comment', null, this.text_, textarea.value)); this.text_ = textarea.value; } @@ -257,7 +257,7 @@ Blockly.Comment.prototype.getText = function() { */ Blockly.Comment.prototype.setText = function(text) { if (this.text_ != text) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.block_, 'comment', null, this.text_, text)); this.text_ = text; } diff --git a/core/connection.js b/core/connection.js index 79dfc63ea..fc13cfaf0 100644 --- a/core/connection.js +++ b/core/connection.js @@ -219,7 +219,7 @@ Blockly.Connection.prototype.connect_ = function(childConnection) { var event; if (Blockly.Events.isEnabled()) { - event = new Blockly.Events.Move(childBlock); + event = new Blockly.Events.BlockMove(childBlock); } // Establish the connections. Blockly.Connection.connectReciprocally_(parentConnection, childConnection); @@ -502,7 +502,7 @@ Blockly.Connection.prototype.disconnectInternal_ = function(parentBlock, childBlock) { var event; if (Blockly.Events.isEnabled()) { - event = new Blockly.Events.Move(childBlock); + event = new Blockly.Events.BlockMove(childBlock); } var otherConnection = this.targetConnection; otherConnection.targetConnection = null; diff --git a/core/contextmenu.js b/core/contextmenu.js index 95f4591ca..ebb8caeb6 100644 --- a/core/contextmenu.js +++ b/core/contextmenu.js @@ -184,7 +184,7 @@ Blockly.ContextMenu.callbackFactory = function(block, xml) { Blockly.Events.enable(); } if (Blockly.Events.isEnabled() && !newBlock.isShadow()) { - Blockly.Events.fire(new Blockly.Events.Create(newBlock)); + Blockly.Events.fire(new Blockly.Events.BlockCreate(newBlock)); } newBlock.select(); }; diff --git a/core/field.js b/core/field.js index 49b671bb5..4060ac62b 100644 --- a/core/field.js +++ b/core/field.js @@ -495,7 +495,7 @@ Blockly.Field.prototype.setValue = function(newValue) { return; } if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.sourceBlock_, 'field', this.name, oldValue, newValue)); } this.setText(newValue); diff --git a/core/field_checkbox.js b/core/field_checkbox.js index 9a834d622..0f2c78c6a 100644 --- a/core/field_checkbox.js +++ b/core/field_checkbox.js @@ -93,7 +93,7 @@ Blockly.FieldCheckbox.prototype.setValue = function(newBool) { (newBool.toUpperCase() == 'TRUE') : !!newBool; if (this.state_ !== newState) { if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.sourceBlock_, 'field', this.name, this.state_, newState)); } this.state_ = newState; diff --git a/core/field_colour.js b/core/field_colour.js index a538ba843..425e4a35c 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -101,7 +101,7 @@ Blockly.FieldColour.prototype.getValue = function() { Blockly.FieldColour.prototype.setValue = function(colour) { if (this.sourceBlock_ && Blockly.Events.isEnabled() && this.colour_ != colour) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.sourceBlock_, 'field', this.name, this.colour_, colour)); } this.colour_ = colour; diff --git a/core/field_dropdown.js b/core/field_dropdown.js index 62d50a37a..7ece4e8dc 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -328,7 +328,7 @@ Blockly.FieldDropdown.prototype.setValue = function(newValue) { return; // No change if null. } if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.sourceBlock_, 'field', this.name, this.value_, newValue)); } this.value_ = newValue; diff --git a/core/field_textinput.js b/core/field_textinput.js index ed7d5af85..a8014a187 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -109,7 +109,7 @@ Blockly.FieldTextInput.prototype.setText = function(newText) { return; } if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.sourceBlock_, 'field', this.name, this.text_, newText)); } Blockly.Field.prototype.setText.call(this, newText); diff --git a/core/field_variable.js b/core/field_variable.js index 1b41909f1..ca31a4a34 100644 --- a/core/field_variable.js +++ b/core/field_variable.js @@ -107,7 +107,7 @@ Blockly.FieldVariable.prototype.getValue = function() { */ Blockly.FieldVariable.prototype.setValue = function(newValue) { if (this.sourceBlock_ && Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( this.sourceBlock_, 'field', this.name, this.value_, newValue)); } if (this.sourceBlock_) { diff --git a/core/mutator.js b/core/mutator.js index a17dc0ae0..613771bcc 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -320,7 +320,7 @@ Blockly.Mutator.prototype.workspaceChanged_ = function() { var newMutationDom = block.mutationToDom(); var newMutation = newMutationDom && Blockly.Xml.domToText(newMutationDom); if (oldMutation != newMutation) { - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( block, 'mutation', null, oldMutation, newMutation)); // Ensure that any bump is part of this mutation's event group. var group = Blockly.Events.getGroup(); diff --git a/core/procedures.js b/core/procedures.js index 24de0306e..deb6046b0 100644 --- a/core/procedures.js +++ b/core/procedures.js @@ -278,7 +278,7 @@ Blockly.Procedures.mutateCallers = function(defBlock) { // undo action since it is deterministically tied to the procedure's // definition mutation. Blockly.Events.recordUndo = false; - Blockly.Events.fire(new Blockly.Events.Change( + Blockly.Events.fire(new Blockly.Events.BlockChange( caller, 'mutation', null, oldMutation, newMutation)); Blockly.Events.recordUndo = oldRecordUndo; } diff --git a/core/workspace_svg.js b/core/workspace_svg.js index b3286b069..38826420f 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -900,7 +900,7 @@ Blockly.WorkspaceSvg.prototype.paste = function(xmlBlock) { Blockly.Events.enable(); } if (Blockly.Events.isEnabled() && !block.isShadow()) { - Blockly.Events.fire(new Blockly.Events.Create(block)); + Blockly.Events.fire(new Blockly.Events.BlockCreate(block)); } block.select(); }; diff --git a/core/xml.js b/core/xml.js index 6356a6c11..c72b312f4 100644 --- a/core/xml.js +++ b/core/xml.js @@ -481,7 +481,7 @@ Blockly.Xml.domToBlock = function(xmlBlock, workspace) { Blockly.Events.enable(); } if (Blockly.Events.isEnabled()) { - Blockly.Events.fire(new Blockly.Events.Create(topBlock)); + Blockly.Events.fire(new Blockly.Events.BlockCreate(topBlock)); } return topBlock; }; diff --git a/demos/blockfactory/workspacefactory/wfactory_init.js b/demos/blockfactory/workspacefactory/wfactory_init.js index 31069b0c5..6b619a76f 100644 --- a/demos/blockfactory/workspacefactory/wfactory_init.js +++ b/demos/blockfactory/workspacefactory/wfactory_init.js @@ -396,8 +396,9 @@ WorkspaceFactoryInit.addWorkspaceFactoryEventListeners_ = function(controller) { // Not listening for Blockly create events because causes the user to drop // blocks when dragging them into workspace. Could cause problems if ever // load blocks into workspace directly without calling updatePreview. - if (e.type == Blockly.Events.MOVE || e.type == Blockly.Events.DELETE || - e.type == Blockly.Events.CHANGE) { + if (e.type == Blockly.Events.BLOCK_MOVE || + e.type == Blockly.Events.BLOCK_DELETE || + e.type == Blockly.Events.BLOCK_CHANGE) { controller.saveStateFromWorkspace(); controller.updatePreview(); } @@ -406,7 +407,7 @@ WorkspaceFactoryInit.addWorkspaceFactoryEventListeners_ = function(controller) { // Only enable "Edit Block" when a block is selected and it has a // surrounding parent, meaning it is nested in another block (blocks that // are not nested in parents cannot be shadow blocks). - if (e.type == Blockly.Events.MOVE || (e.type == Blockly.Events.UI && + if (e.type == Blockly.Events.BLOCK_MOVE || (e.type == Blockly.Events.UI && e.element == 'selected')) { var selected = Blockly.selected; @@ -480,7 +481,7 @@ WorkspaceFactoryInit.addWorkspaceFactoryEventListeners_ = function(controller) { // Convert actual shadow blocks added from the toolbox to user-generated // shadow blocks. - if (e.type == Blockly.Events.CREATE) { + if (e.type == Blockly.Events.BLOCK_CREATE) { controller.convertShadowBlocks(); // Let the user create a Variables or Functions category if they use