mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Cleanup in FieldLabelEditable
This commit is contained in:
parent
3cdc7905c9
commit
2f378736f7
1 changed files with 2 additions and 20 deletions
|
@ -51,31 +51,13 @@ goog.inherits(Blockly.FieldLabelEditable, Blockly.FieldLabel);
|
|||
*/
|
||||
Blockly.FieldLabelEditable.prototype.EDITABLE = true;
|
||||
|
||||
/**
|
||||
* Returns the height and width of the field.
|
||||
* @return {!goog.math.Size} Height and width.
|
||||
*/
|
||||
Blockly.FieldLabelEditable.prototype.getSize = function() {
|
||||
if (!this.size_.width) {
|
||||
this.render_();
|
||||
}
|
||||
return this.size_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the width of the field. This calls getCachedWidth which won't cache
|
||||
* the approximated width on IE/Edge when `getComputedTextLength` fails. Once
|
||||
* it eventually does succeed, the result will be cached.
|
||||
**/
|
||||
Blockly.FieldLabelEditable.prototype.updateWidth = function() {
|
||||
// Calculate width of field
|
||||
var width = Blockly.Field.getCachedWidth(this.textElement_);
|
||||
|
||||
// Add padding to any drawn box.
|
||||
if (this.box_) {
|
||||
width += 2 * Blockly.BlockSvg.BOX_FIELD_PADDING;
|
||||
}
|
||||
|
||||
// Set width of the field.
|
||||
this.size_.width = width;
|
||||
// Unlike a the base Field class, this doesn't add space to editable fields.
|
||||
this.size_.width = Blockly.Field.getCachedWidth(this.textElement_);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue