diff --git a/core/field_colour.js b/core/field_colour.js index 30b7dc5e2..a538ba843 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -231,4 +231,5 @@ Blockly.FieldColour.widgetDispose_ = function() { if (Blockly.FieldColour.changeEventKey_) { goog.events.unlistenByKey(Blockly.FieldColour.changeEventKey_); } + Blockly.Events.setGroup(false); }; diff --git a/core/field_date.js b/core/field_date.js index 24f3239e4..9e19c63ac 100644 --- a/core/field_date.js +++ b/core/field_date.js @@ -165,6 +165,7 @@ Blockly.FieldDate.widgetDispose_ = function() { if (Blockly.FieldDate.changeEventKey_) { goog.events.unlistenByKey(Blockly.FieldDate.changeEventKey_); } + Blockly.Events.setGroup(false); }; /** diff --git a/core/field_dropdown.js b/core/field_dropdown.js index 3976cba40..70ac3b9f4 100644 --- a/core/field_dropdown.js +++ b/core/field_dropdown.js @@ -133,6 +133,7 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() { thisField.onItemSelected(menu, menuItem); } Blockly.WidgetDiv.hideIfOwner(thisField); + Blockly.Events.setGroup(false); } var menu = new goog.ui.Menu(); diff --git a/core/field_textinput.js b/core/field_textinput.js index e95ead82b..5c6e66215 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -94,6 +94,27 @@ Blockly.FieldTextInput.prototype.setValue = function(newValue) { Blockly.Field.prototype.setValue.call(this, newValue); }; +/** + * Set the text in this field and fire a change event. + * @param {*} newText New text. + */ +Blockly.FieldTextInput.prototype.setText = function(newText) { + if (newText === null) { + // No change if null. + return; + } + newText = String(newText); + if (newText === this.text_) { + // No change. + return; + } + if (this.sourceBlock_ && Blockly.Events.isEnabled()) { + Blockly.Events.fire(new Blockly.Events.Change( + this.sourceBlock_, 'field', this.name, this.text_, newText)); + } + Blockly.Field.prototype.setText.call(this, newText); +}; + /** * Set whether this field is spellchecked by the browser. * @param {boolean} check True if checked. @@ -290,6 +311,7 @@ Blockly.FieldTextInput.prototype.widgetDispose_ = function() { thisField.workspace_.removeChangeListener( htmlInput.onWorkspaceChangeWrapper_); Blockly.FieldTextInput.htmlInput_ = null; + Blockly.Events.setGroup(false); // Delete style properties. var style = Blockly.WidgetDiv.DIV.style; style.width = 'auto';