mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
Add Create, Delete, and Change events.
Not counting change for mutators.
This commit is contained in:
@@ -42,7 +42,7 @@ goog.require('goog.userAgent');
|
||||
*/
|
||||
Blockly.Field = function(text) {
|
||||
this.size_ = new goog.math.Size(0, 25);
|
||||
this.setText(text);
|
||||
this.setValue(text);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -139,6 +139,10 @@ Blockly.Field.prototype.init = function(block) {
|
||||
Blockly.bindEvent_(this.fieldGroup_, 'mouseup', this, this.onMouseUp_);
|
||||
// Force a render.
|
||||
this.updateTextNode_();
|
||||
if (Blockly.Events.isEnabled()) {
|
||||
Blockly.Events.fire(new Blockly.Events.Change(
|
||||
this.sourceBlock_, 'field', this.name, '', this.getValue()));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -326,7 +330,6 @@ Blockly.Field.prototype.setText = function(text) {
|
||||
if (this.sourceBlock_ && this.sourceBlock_.rendered) {
|
||||
this.sourceBlock_.render();
|
||||
this.sourceBlock_.bumpNeighbours_();
|
||||
this.sourceBlock_.workspace.fireChangeEvent();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -386,6 +389,10 @@ Blockly.Field.prototype.setValue = function(newText) {
|
||||
if (oldText == newText) {
|
||||
return;
|
||||
}
|
||||
if (this.sourceBlock_ && Blockly.Events.isEnabled()) {
|
||||
Blockly.Events.fire(new Blockly.Events.Change(
|
||||
this.sourceBlock_, 'field', this.name, oldText, newText));
|
||||
}
|
||||
this.setText(newText);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user