From 45387faab7bc6adc3707868056b073e484b92706 Mon Sep 17 00:00:00 2001 From: alschmiedt Date: Tue, 2 Jul 2019 10:53:45 -0700 Subject: [PATCH] Adds type to FieldNumber editor --- core/css.js | 8 ++++++++ core/field_number.js | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/core/css.js b/core/css.js index 1fa075011..f0694a898 100644 --- a/core/css.js +++ b/core/css.js @@ -790,6 +790,14 @@ Blockly.Css.CONTENT = [ 'border: 1px solid #000 !important;', '}', + /* Remove the increase and decrease arrows on the field number editor */ + 'input.blocklyHtmlInput[type=number]::-webkit-inner-spin-button,', + 'input.blocklyHtmlInput[type=number]::-webkit-outer-spin-button {', + '-webkit-appearance: none;', + 'margin: 0;', + '}', + + /* Copied from: goog/css/menu.css */ /* * Copyright 2009 The Closure Library Authors. All Rights Reserved. diff --git a/core/field_number.js b/core/field_number.js index 2e729d193..88e62e763 100644 --- a/core/field_number.js +++ b/core/field_number.js @@ -99,6 +99,18 @@ Blockly.FieldNumber.prototype.setConstraints = function(min, max, precision) { this.setValue(this.getValue()); }; +/** + * Show the inline free-text editor on top of the text. + * @param {boolean=} opt_quietInput True if editor should be created without + * focus. Defaults to false. + * @protected + */ +Blockly.FieldNumber.prototype.showEditor_ = function(opt_quietInput) { + this.setSpellcheck(false); + Blockly.FieldNumber.superClass_.showEditor_.call(this, opt_quietInput); + this.htmlInput_.type = "number"; +}; + /** * Ensure that the input value is a valid number (must fulfill the * constraints placed on the field).