From 7568e9bdf671458d23b1bd2a2ff4bd724a15080a Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Thu, 1 Feb 2024 01:53:12 +0000 Subject: [PATCH] Done, I think --- core/field_textdropdown.js | 71 +++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 24 deletions(-) diff --git a/core/field_textdropdown.js b/core/field_textdropdown.js index c8f9b2b1f8..cc7c2b00bf 100644 --- a/core/field_textdropdown.js +++ b/core/field_textdropdown.js @@ -144,18 +144,6 @@ Blockly.FieldTextDropdown.prototype.init = function() { this.disableColourChange_ = true; }; -/** - * Close the input widget if this input is being deleted. - */ -Blockly.FieldTextDropdown.prototype.dispose = function() { - if (this.mouseUpWrapper_) { - Blockly.unbindEvent_(this.mouseUpWrapper_); - this.mouseUpWrapper_ = null; - Blockly.Touch.clearTouchIdentifier(); - } - Blockly.FieldTextDropdown.superClass_.dispose.call(this); -}; - /** * If the drop-down isn't open, show the text editor. */ @@ -172,10 +160,21 @@ Blockly.FieldTextDropdown.prototype.showEditor_ = function() { }; /** - * @return {boolean} True if the option list is generated by a function. - * Otherwise false. + * Callback when the drop-down menu is hidden. */ -Blockly.FieldTextDropdown.prototype.isOptionListDynamic = Blockly.FieldDropdown.prototype.isOptionListDynamic; +Blockly.FieldTextDropdown.prototype.onHide = Blockly.FieldDropdown.prototype.onHide; + +/** + * Handle the selection of an item in the dropdown menu. + * @param {!goog.ui.Menu} menu The Menu component clicked. + * @param {!goog.ui.MenuItem} menuItem The MenuItem selected within menu. + */ +Blockly.FieldTextDropdown.prototype.onItemSelected = Blockly.FieldDropdown.prototype.onItemSelected; + +/** + * @private + */ +Blockly.FieldTextDropdown.prototype.trimOptions_ = Blockly.FieldDropdown.prototype.trimOptions_; /** * Return a list of the options for this dropdown. @@ -186,6 +185,30 @@ Blockly.FieldTextDropdown.prototype.isOptionListDynamic = Blockly.FieldDropdown. */ Blockly.FieldTextDropdown.prototype.getOptions = Blockly.FieldDropdown.prototype.getOptions; +/** + * Get the language-neutral value from this dropdown menu. + * @return {string} Current text. + */ +Blockly.FieldTextDropdown.prototype.getValue = Blockly.FieldDropdown.prototype.getValue; + +/** + * Set the language-neutral value for this dropdown menu. + * @param {string} newValue New value to set. + */ +Blockly.FieldTextDropdown.prototype.setValue = Blockly.FieldDropdown.prototype.setValue; + +/** + * Sets the text in this field. Trigger a rerender of the source block. + * @param {?string} text New text. + */ +Blockly.FieldTextDropdown.prototype.setText = Blockly.FieldDropdown.prototype.setText; + +/** + * @return {boolean} True if the option list is generated by a function. + * Otherwise false. + */ +Blockly.FieldTextDropdown.prototype.isOptionListDynamic = Blockly.FieldDropdown.prototype.isOptionListDynamic; + /** * Position a drop-down arrow at the appropriate location at render-time. * See: Blockly.FieldDropDown.prototype.positionArrow. @@ -201,15 +224,15 @@ Blockly.FieldTextDropdown.prototype.positionArrow = Blockly.FieldDropdown.protot Blockly.FieldTextDropdown.prototype.showDropdown_ = Blockly.FieldDropdown.prototype.showEditor_; /** - * Handle the selection of an item in the dropdown menu. - * @param {!goog.ui.Menu} menu The Menu component clicked. - * @param {!goog.ui.MenuItem} menuItem The MenuItem selected within menu. - */ -Blockly.FieldTextDropdown.prototype.onItemSelected = Blockly.FieldDropdown.prototype.onItemSelected; - -/** - * Callback when the drop-down menu is hidden. + * Close the input widget if this input is being deleted. */ -Blockly.FieldTextDropdown.prototype.onHide = Blockly.FieldDropdown.prototype.onHide; +Blockly.FieldTextDropdown.prototype.dispose = function() { + if (this.mouseUpWrapper_) { + Blockly.unbindEvent_(this.mouseUpWrapper_); + this.mouseUpWrapper_ = null; + Blockly.Touch.clearTouchIdentifier(); + } + Blockly.FieldTextDropdown.superClass_.dispose.call(this); +}; Blockly.Field.register('field_textdropdown', Blockly.FieldTextDropdown);