Skip to main content

Home > blockly > FieldDropdown

FieldDropdown class

Class for an editable dropdown field.

Signature:

export declare class FieldDropdown extends Field<string> 

Extends: Field<string>

Constructors

ConstructorModifiersDescription
(constructor)(menuGenerator, validator, config)Constructs a new instance of the FieldDropdown class
(constructor)(menuGenerator)Constructs a new instance of the FieldDropdown class

Properties

PropertyModifiersTypeDescription
ARROW_CHARstaticstring
clickTarget_SVGElement | null
IMAGE_Y_OFFSETprotected staticnumberThe y offset from the top of the field to the top of the image, if an image is selected.
IMAGE_Y_PADDINGprotected staticnumberThe total vertical padding above and below an image.
menu_protectedMenu | nullThe dropdown menu.
menuGenerator_?protectedMenuGenerator(Optional)
SEPARATORstatic readonly(not declared)Magic constant used to represent a separator in a list of dropdown items.
SERIALIZABLEbooleanSerializable fields are saved by the serializer, non-serializable fields are not. Editable fields should also be serializable.

Methods

MethodModifiersDescription
applyColour()Updates the dropdown arrow to match the colour/style of the block.
createSVGArrow_()protectedCreate an SVG based arrow.
createTextArrow_()protectedCreate a tspan based arrow.
doClassValidation_(newValue)protectedEnsure that the input value is a valid language-neutral option.
doClassValidation_(newValue)protected
doValueUpdate_(newValue)protectedUpdate the value of this dropdown field.
dropdownDispose_()protectedDisposes of events and DOM-references belonging to the dropdown editor.
getOptions(useCache)Return a list of the options for this dropdown.
getText_()protectedUse 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. If the selected option is an HTMLElement, return the title, ariaLabel, or innerText of the element. If you use HTMLElement options in Node.js and call this function, ensure that you are supplying an implementation of HTMLElement, such as through jsdom-global.
initView()Create the block UI for this dropdown.
isOptionListDynamic()
onItemSelected_(menu, menuItem)protectedHandle the selection of an item in the dropdown menu.
render_()protectedDraws the border with the correct width.
setOptions(menuGenerator)Update the options on this dropdown. This will reset the selected item to the first item in the list.
shouldAddBorderRect_()protectedWhether or not the dropdown should add a border rect.
showEditor_(e)protectedCreate a dropdown menu under the text.
trimOptions(options)protectedFactor out common words in statically defined options. Create prefix and/or suffix labels.
validateOptions(options)protectedValidates the data structure to be processed as an options list.