Fix mutator field scale (#3763)

* Fix mutator zoom scale
This commit is contained in:
Sam El-Husseini
2020-03-23 17:34:12 -07:00
committed by GitHub
parent 40d39fd0c5
commit 71f7285333
4 changed files with 18 additions and 3 deletions

View File

@@ -208,7 +208,7 @@ Blockly.FieldMultilineInput.prototype.updateSize_ = function() {
*/
Blockly.FieldMultilineInput.prototype.widgetCreate_ = function() {
var div = Blockly.WidgetDiv.DIV;
var scale = this.workspace_.scale;
var scale = this.workspace_.getScale();
var htmlInput =
/** @type {HTMLTextAreaElement} */ (document.createElement('textarea'));

View File

@@ -330,7 +330,7 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
var htmlInput = /** @type {HTMLInputElement} */ (document.createElement('input'));
htmlInput.className = 'blocklyHtmlInput';
htmlInput.setAttribute('spellcheck', this.spellcheck_);
var scale = this.workspace_.scale;
var scale = this.workspace_.getScale();
var fontSize =
(this.getConstants().FIELD_TEXT_FONTSIZE * scale) + 'pt';
div.style.fontSize = fontSize;

View File

@@ -2152,6 +2152,19 @@ Blockly.WorkspaceSvg.prototype.setScale = function(newScale) {
}
};
/**
* Get the workspace's zoom factor. If the workspace has a parent, we call into
* the parent to get the workspace scale.
* @return {number} The workspace zoom factor. Units: (pixels / workspaceUnit).
*/
Blockly.WorkspaceSvg.prototype.getScale = function() {
if (this.options.parentWorkspace) {
return this.options.parentWorkspace.getScale();
}
return this.scale;
};
/**
* Scroll the workspace to a specified offset (in pixels), keeping in the
* workspace bounds. See comment on workspaceSvg.scrollX for more detail on

View File

@@ -217,7 +217,9 @@ suite('Text Input Fields', function() {
setup(function() {
this.prepField = function(field) {
var workspace = {
scale: 1,
getScale: function() {
return 1;
},
getRenderer: function() { return {
getClassName: function() { return ''; }
}; },