Creates a dropdown menu <select></select> element.
The parameter is optional. If true is passed, as in let mySelect = createSelect(true), then the dropdown will support multiple selections. If an existing <select></select> element is passed, as in let mySelect = createSelect(otherSelect), the existing element will be wrapped in a new p5.Element object.
Dropdowns extend the p5.Element class with a few helpful methods for managing options:
mySelect.option(name, [value])adds an option to the menu. The first paremeter,name, is a string that sets the option's name and value. The second parameter,value, is optional. If provided, it sets the value that corresponds to the keyname. If an option withnamealready exists, its value is changed tovalue.mySelect.value()returns the currently-selected option's value.mySelect.selected()returns the currently-selected option.mySelect.selected(option)selects the given option by default.mySelect.disable()marks the whole dropdown element as disabled.mySelect.disable(option)marks a given option as disabled.mySelect.enable()marks the whole dropdown element as enabled.mySelect.enable(option)marks a given option as enabled.
Examples
Syntax
createSelect([multiple])
createSelect(existing)
Parameters
multiple
Boolean:
support multiple selections.
existing
Object:
select element to wrap, either as a p5.Element or a HTMLSelectElement.
Returns
p5.Element: new p5.Element object.
This page is generated from the comments in src/dom/dom.js . Please feel free to edit it and submit a pull request!