diff --git a/core/block.js b/core/block.js index f70f8e966..8fee8d4a9 100644 --- a/core/block.js +++ b/core/block.js @@ -1338,11 +1338,7 @@ Blockly.Block.prototype.toString = function(opt_maxLength, opt_emptyToken) { } else { for (var i = 0, input; input = this.inputList[i]; i++) { for (var j = 0, field; field = input.fieldRow[j]; j++) { - if (field instanceof Blockly.FieldDropdown && !field.getValue()) { - text.push(emptyFieldPlaceholder); - } else { - text.push(field.getText()); - } + text.push(field.getText()); } if (input.connection) { var child = input.connection.targetBlock(); diff --git a/core/block_svg.js b/core/block_svg.js index d322eb56c..b176bc0a4 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -632,8 +632,7 @@ Blockly.BlockSvg.prototype.createTabList_ = function() { var list = []; for (var i = 0, input; input = this.inputList[i]; i++) { for (var j = 0, field; field = input.fieldRow[j]; j++) { - if (field instanceof Blockly.FieldTextInput && field.isVisible()) { - // TODO (#1276): Also support dropdown fields. + if (field.isTabNavigable() && field.isVisible()) { list.push(field); } } diff --git a/core/field.js b/core/field.js index b4651ec7a..f8220349d 100644 --- a/core/field.js +++ b/core/field.js @@ -913,6 +913,22 @@ Blockly.Field.prototype.getParentInput = function() { return parentInput; }; +/** + * Returns whether or not we should flip the field in RTL. + * @return {boolean} True if we should flip in RTL. + */ +Blockly.Field.prototype.getFlipRtl = function() { + return false; +}; + +/** + * Returns whether or not the field is tab navigable. + * @return {boolean} True if the field is tab navigable. + */ +Blockly.Field.prototype.isTabNavigable = function() { + return false; +}; + /** * Handles the given action. * This is only triggered when keyboard accessibility mode is enabled. diff --git a/core/field_colour.js b/core/field_colour.js index 3a05fbb70..34ede9b86 100644 --- a/core/field_colour.js +++ b/core/field_colour.js @@ -35,6 +35,7 @@ goog.require('Blockly.utils.aria'); goog.require('Blockly.utils.colour'); goog.require('Blockly.utils.dom'); goog.require('Blockly.utils.IdGenerator'); +goog.require('Blockly.utils.KeyCodes'); goog.require('Blockly.utils.object'); goog.require('Blockly.utils.Size'); diff --git a/core/field_image.js b/core/field_image.js index 101537a8f..fe36060e3 100644 --- a/core/field_image.js +++ b/core/field_image.js @@ -218,6 +218,7 @@ Blockly.FieldImage.prototype.doValueUpdate_ = function(newValue) { /** * Get whether to flip this image in RTL * @return {boolean} True if we should flip in RTL. + * @override */ Blockly.FieldImage.prototype.getFlipRtl = function() { return this.flipRtl_; diff --git a/core/field_textinput.js b/core/field_textinput.js index 159a30ef5..94fbb46f3 100644 --- a/core/field_textinput.js +++ b/core/field_textinput.js @@ -35,6 +35,7 @@ goog.require('Blockly.utils'); goog.require('Blockly.utils.aria'); goog.require('Blockly.utils.Coordinate'); goog.require('Blockly.utils.dom'); +goog.require('Blockly.utils.KeyCodes'); goog.require('Blockly.utils.object'); goog.require('Blockly.utils.Size'); goog.require('Blockly.utils.userAgent'); @@ -357,15 +358,14 @@ Blockly.FieldTextInput.prototype.unbindInputEvents_ = function() { * @protected */ Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_ = function(e) { - var tabKey = 9, enterKey = 13, escKey = 27; - if (e.keyCode == enterKey) { + if (e.keyCode == Blockly.utils.KeyCodes.ENTER) { Blockly.WidgetDiv.hide(); Blockly.DropDownDiv.hideWithoutAnimation(); - } else if (e.keyCode == escKey) { + } else if (e.keyCode == Blockly.utils.KeyCodes.ESC) { this.htmlInput_.value = this.htmlInput_.defaultValue; Blockly.WidgetDiv.hide(); Blockly.DropDownDiv.hideWithoutAnimation(); - } else if (e.keyCode == tabKey) { + } else if (e.keyCode == Blockly.utils.KeyCodes.TAB) { Blockly.WidgetDiv.hide(); Blockly.DropDownDiv.hideWithoutAnimation(); this.sourceBlock_.tab(this, !e.shiftKey); @@ -479,6 +479,15 @@ Blockly.FieldTextInput.nonnegativeIntegerValidator = function(text) { return n; }; +/** + * Returns whether or not the field is tab navigable. + * @return {boolean} True if the field is tab navigable. + * @override + */ +Blockly.FieldTextInput.prototype.isTabNavigable = function() { + return true; +}; + /** * Use the `getText_` developer hook to override the field's text representation. * When we're currently editing, return the current html value instead. diff --git a/core/renderers/measurables/row_elements.js b/core/renderers/measurables/row_elements.js index cfc12c83a..d3664cc8f 100644 --- a/core/renderers/measurables/row_elements.js +++ b/core/renderers/measurables/row_elements.js @@ -95,7 +95,7 @@ Blockly.blockRendering.Field = function(constants, field, parentInput) { Blockly.blockRendering.Field.superClass_.constructor.call(this, constants); this.field = field; this.isEditable = field.isCurrentlyEditable(); - this.flipRtl = field instanceof Blockly.FieldImage && field.getFlipRtl(); + this.flipRtl = field.getFlipRtl(); this.type |= Blockly.blockRendering.Types.FIELD; var size = this.field.getSize();