Unverified Commit 47628a85 authored by Beka Westberg's avatar Beka Westberg Committed by GitHub

Fix number block displaying non-number values (#2073)

parent 90c6d5e3
...@@ -143,6 +143,7 @@ ...@@ -143,6 +143,7 @@
"./src/language_switch.js", "./src/language_switch.js",
"./src/warning.js", "./src/warning.js",
"./src/toolboxController.js", "./src/toolboxController.js",
"./src/field.js",
// Dialog Utiltiy // Dialog Utiltiy
"./src/util.js", "./src/util.js",
......
// -*- mode: java; c-basic-offset: 2; -*-
// Copyright © 2016 Massachusetts Institute of Technology. All rights reserved.
/**
* @license
* @fileoverview Visual blocks editor for MIT App Inventor
* Add additional "class methods" to Blockly.Field
*/
'use strict';
goog.provide('AI.Blockly.Field');
goog.require('Blockly.Field');
/**
* Sets the value of the field. Since AI runs an older version of blockly,
* the newValue should always be a string.
*
* This is overridden so that the field correctly updates the display text
* even if the newValue is the same as the old value.
* @param {string} newValue The new value.
*/
Blockly.Field.prototype.setValue = function(newValue) {
if (newValue === null) {
return null; // No change if null;
}
var oldValue = this.getValue(); // Must get value before setting text.
this.setText(newValue); // Always update text. See #1238.
if (this.sourceBlock_ && Blockly.Events.isEnabled() && newValue != oldValue) {
Blockly.Events.fire(new Blockly.Events.Change(
this.sourceBlock_, 'field', this.name, oldValue, newValue));
}
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment