blockly > FieldDropdown

FieldDropdown class

Class for an editable dropdown field.


export declare class FieldDropdown extends Field<string> 

Extends: Field<string>


Constructor Modifiers Description
(constructor)(menuGenerator, validator, config) Constructs a new instance of the FieldDropdown class
(constructor)(menuGenerator) Constructs a new instance of the FieldDropdown class


Property Modifiers Type Description
ARROW_CHAR static string
CHECKMARK_OVERHANG static number Horizontal distance that a checkmark overhangs the dropdown.
clickTarget_ SVGElement | null
CURSOR string Mouse cursor style when over the hotspot that initiates the editor.
MAX_MENU_HEIGHT_VH static number Maximum height of the dropdown menu, as a percentage of the viewport height.
menu_ protected Menu | null The dropdown menu.
menuGenerator_? protected MenuGenerator (Optional)
SERIALIZABLE boolean Serializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable.


Method Modifiers Description
applyColour() Updates the dropdown arrow to match the colour/style of the block.
createSVGArrow_() protected Create an SVG based arrow.
createTextArrow_() protected Create a tspan based arrow.
doClassValidation_(newValue) protected Ensure that the input value is a valid language-neutral option.
doValueUpdate_(newValue) protected Update the value of this dropdown field.
dropdownDispose_() protected Disposes of events and DOM-references belonging to the dropdown editor.
getOptions(useCache) Return a list of the options for this dropdown.
getText_() protected Use the getText_ developer hook to override the field's text representation. Get the selected option text. If the selected option is an image we return the image alt text.
initView() Create the block UI for this dropdown.
onItemSelected_(menu, menuItem) protected Handle the selection of an item in the dropdown menu.
render_() protected Draws the border with the correct width.
shouldAddBorderRect_() protected Whether or not the dropdown should add a border rect.
showEditor_(e) protected Create a dropdown menu under the text.