mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
Fix setting focus for workspace (#3425)
* Fix setting focus for workspace
This commit is contained in:
@@ -269,7 +269,7 @@ Blockly.FieldTextInput.prototype.showInlineEditor_ = function(quietInput) {
|
||||
this.isBeingEdited_ = true;
|
||||
|
||||
if (!quietInput) {
|
||||
this.htmlInput_.focus();
|
||||
this.htmlInput_.focus({preventScroll:true});
|
||||
this.htmlInput_.select();
|
||||
}
|
||||
};
|
||||
@@ -349,6 +349,10 @@ Blockly.FieldTextInput.prototype.bindInputEvents_ = function(htmlInput) {
|
||||
this.onKeyInputWrapper_ =
|
||||
Blockly.bindEventWithChecks_(
|
||||
htmlInput, 'input', this, this.onHtmlInputChange_);
|
||||
|
||||
this.onBlurInputWrapper_ =
|
||||
Blockly.bindEventWithChecks_(
|
||||
htmlInput, 'blur', this, this.onHtmlInputBlur_);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -362,6 +366,9 @@ Blockly.FieldTextInput.prototype.unbindInputEvents_ = function() {
|
||||
if (this.onKeyInputWrapper_) {
|
||||
Blockly.unbindEvent_(this.onKeyInputWrapper_);
|
||||
}
|
||||
if (this.onBlurInputWrapper_) {
|
||||
Blockly.unbindEvent_(this.onBlurInputWrapper_);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -406,6 +413,16 @@ Blockly.FieldTextInput.prototype.onHtmlInputChange_ = function(_e) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle blur for the editor.
|
||||
* @param {!Event} _e Focus event.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.onHtmlInputBlur_ = function(_e) {
|
||||
Blockly.WidgetDiv.hide();
|
||||
Blockly.DropDownDiv.hideWithoutAnimation();
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the html input value and the field's internal value. The difference
|
||||
* between this and ``setValue`` is that this also updates the html input
|
||||
|
||||
Reference in New Issue
Block a user