Center text field input when editing (#2776)

* Center text field input when editing
This commit is contained in:
Sam El-Husseini
2019-08-05 11:23:47 -07:00
committed by GitHub
parent 109f1ad676
commit 9203517f3d
2 changed files with 7 additions and 11 deletions

View File

@@ -537,8 +537,9 @@ Blockly.Css.CONTENT = [
'height: 100%;',
'margin: 0;',
'outline: none;',
'padding: 0 1px;',
'width: 100%',
'padding: 0;',
'width: 100%;',
'text-align: center;',
'}',
'.blocklyMainBackground {',

View File

@@ -301,14 +301,10 @@ Blockly.FieldTextInput.prototype.bindInputEvents_ = function(htmlInput) {
this.onKeyDownWrapper_ =
Blockly.bindEventWithChecks_(
htmlInput, 'keydown', this, this.onHtmlInputKeyDown_);
// Resize after every keystroke.
this.onKeyUpWrapper_ =
// Resize after every input change.
this.onKeyInputWrapper_ =
Blockly.bindEventWithChecks_(
htmlInput, 'keyup', this, this.onHtmlInputChange_);
// Repeatedly resize when holding down a key.
this.onKeyPressWrapper_ =
Blockly.bindEventWithChecks_(
htmlInput, 'keypress', this, this.onHtmlInputChange_);
htmlInput, 'input', this, this.onHtmlInputChange_);
};
/**
@@ -317,8 +313,7 @@ Blockly.FieldTextInput.prototype.bindInputEvents_ = function(htmlInput) {
*/
Blockly.FieldTextInput.prototype.unbindInputEvents_ = function() {
Blockly.unbindEvent_(this.onKeyDownWrapper_);
Blockly.unbindEvent_(this.onKeyUpWrapper_);
Blockly.unbindEvent_(this.onKeyPressWrapper_);
Blockly.unbindEvent_(this.onKeyInputWrapper_);
};
/**