class ComboBox
- Extends:
- UIComponent
Description:
ComboBox UI component that extends UIComponent class.
Check examples below and become familiar with a ListItem object format.
Constructor
constructor([items])
ComboBox constructor.
Accepts an optional Array parameter: strings ["Item 1","Item 2", ...], numbers [1, 2, 3, ...], item objects [{text:"Item 1"}, {text:"Item 2"}, ...], or a mixture of them.
Parameters:
| Name | Type | Description |
|---|---|---|
|
|
Array.<(string|number|ListItem)> |
Items as an Array of objects, strings or numbers. Can be a mix of these types. For item Object's format check out add() method example . |
Members
- [ readonly ] childCount
- [ readonly ] children
- [ readonly ] container
- [ readonly ] id
- [ readonly ] length
- [ readonly ] parent
- [ readonly ] screenPosition
- [ readonly ] selectedItem
Methods
From this class:
- add()
- clear()
- indexOf()
- item()
- itemPadding()
- items()
- onPopupEvents()
- open()
- popupSize()
- selectedIndex()
- selectedValue()
Inherited from UIComponent:
- addTo()
- anchor()
- background()
- border()
- bottom()
- caretPosition()
- center()
- color()
- contextMenu()
- copySelection()
- cursor()
- cutSelection()
- deleteSelection()
- destroy()
- dragAction()
- dragData()
- dragDataType()
- dropAction()
- dropDataType()
- dropMode()
- editable()
- emit()
- emitFocusKeyEvents()
- enabled()
- focusable()
- focused()
- font()
- getAncestor()
- getWindow()
- height()
- hide()
- index()
- isInside()
- layer()
- maxSize()
- minSize()
- move()
- onAction()
- onAncestorEvents()
- onCaretEvents()
- onChange()
- onComponentEvents()
- onDispose()
- onDragEvents()
- onDropEvents()
- onError()
- onFocusEvents()
- onKey()
- onMouseEvents()
- onMouseMotion()
- onMouseWheel()
- onPropertyChange()
- opacity()
- paste()
- position()
- remove()
- right()
- selectAll()
- selection()
- size()
- snapshot()
- text()
- tooltip()
- undoEnabled()
- undoLimit()
- updateUI()
- verifyComponent()
- visible()
- width()
- x()
- y()
Examples:
// ListItem object format:
ListItem {
text: string, // Item text (required only for a new item).
id: string|number, // Value that can be used by software logic to identify this item
value: string|number, // Additional value to be stored in the item for later use.
icon: string, // Absolute or relative path to icon image, base64 encoded image string, or `null` to remove icon.
color: string, // Item text color as a 6 character hex encoded color string (e.g. #665500)
background: string, // Item background color as a 6 character hex encoded color string (e.g. #665500)
tooltip: string, // Tooltip text to show when pointer hover the item. (in List and Tree components only)
font: Font // Object{name: string, size: number, bold: boolean, ...}. See complete list of font properties in example of font() method.
}
// Creating combo box, then adding each item separately.
const combo1 = new ComboBox().add("Item 1").add(45).add({text: "Item 2", font:{bolt:true}});
// Creating combo box, then adding items as an array.
const combo2 = new ComboBox().items([
"Item 1",
45,
{text: "Item 3", font:{bolt:true}}
]);
// Creating combo box with items as a string and object. Items can be a mix of strings and objects.
const combo3 = new ComboBox([
"Item 1",
45,
{text: "Item 3", font:{bolt:true}}
]);
