### Import :
```js
const DropdownButton = brackets.getModule("widgets/DropdownButton")
```
## EVENT\_SELECTED : string
Event triggered when an item is selected.
**Kind**: global constant
## EVENT\_LIST\_RENDERED : string
Event triggered when the list is rendered.
**Kind**: global constant
## EVENT\_DROPDOWN\_SHOWN : string
Event triggered when the dropdown is shown.
**Kind**: global constant
## EVENT\_DROPDOWN\_CLOSED : string
Event triggered when the dropdown is closed.
**Kind**: global constant
## DropdownButton(label, items, [itemRenderer], [options])
Creates a single dropdown-button instance. The DOM node is created but not attached to
the document anywhere - clients should append `this.$button` to the appropriate location.
DropdownButton dispatches the following events:
- "select" - triggered when an option in the dropdown is clicked. Passed item object and index.
**Kind**: global function
| Param | Type | Default | Description |
| --- | --- | --- | --- |
| label | string | | The label to display on the button. |
| items | Array.<\*> | | Items in the dropdown list. Items can have any type/value. An item with the value `"---"` will be treated as a divider, which is not clickable, and `itemRenderer()` will not be called for it. |
| [itemRenderer] | function | | Optional function to convert a single item to HTML. If not provided, items are assumed to be plain text strings. The function receives the item and its index. |
| [options] | Object | | Additional options for the dropdown. |
| [options.enableFilter] | boolean | false | Set to `true` to enable filtering by typing. |
| [options.cssClasses] | string | | A space-separated list of CSS classes to apply to the button. |
| [options.customFilter] | function | | Optional. When `enableFilter` is enabled, this function is used as a custom filtering callback. It receives the user's search text, the text of the element being filtered, and the element's index. Return `true` to display the list item, or `false` to hide it. |
* [DropdownButton(label, items, [itemRenderer], [options])](#DropdownButton)
* [.items](#DropdownButton+items) : Array.<\*>
* [.itemsSearchFilterText](#DropdownButton+itemsSearchFilterText) : null
* [.$button](#DropdownButton+$button) : jQueryObject
* [.$dropdown](#DropdownButton+$dropdown) : jQueryObject
* [.dropdownExtraClasses](#DropdownButton+dropdownExtraClasses) : string
* [.setButtonLabel(label)](#DropdownButton+setButtonLabel)
* [.isOpen()](#DropdownButton+isOpen)
* [.itemRenderer(item, index)](#DropdownButton+itemRenderer) ⇒ string \| Object
* [.refresh()](#DropdownButton+refresh)
* [.setChecked(index, checked)](#DropdownButton+setChecked)
* [.showDropdown()](#DropdownButton+showDropdown)
* [.filterDropdown(searchString)](#DropdownButton+filterDropdown)
* [.closeDropdown()](#DropdownButton+closeDropdown)
* [.toggleDropdown()](#DropdownButton+toggleDropdown)
### dropdownButton.items : Array.<\*>
Items in dropdown list - may be changed any time dropdown isn't open
**Kind**: instance property of [DropdownButton](#DropdownButton)
### dropdownButton.itemsSearchFilterText : null
This is filter text corresponding to each items. it will be used to filter the items based on
the keyboard key presses the user does to enter search filter in popup.
**Kind**: instance property of [DropdownButton](#DropdownButton)
### dropdownButton.$button : jQueryObject
The clickable button. Available as soon as the DropdownButton is constructed.
**Kind**: instance property of [DropdownButton](#DropdownButton)
### dropdownButton.$dropdown : jQueryObject
The dropdown element. Only non-null while open.
**Kind**: instance property of [DropdownButton](#DropdownButton)
### dropdownButton.dropdownExtraClasses : string
Extra CSS class(es) to apply to $dropdown
**Kind**: instance property of [DropdownButton](#DropdownButton)
### dropdownButton.setButtonLabel(label)
Update the button label.
**Kind**: instance method of [DropdownButton](#DropdownButton)
| Param | Type |
| --- | --- |
| label | string |
### dropdownButton.isOpen()
returns true if the dropdown is open
**Kind**: instance method of [DropdownButton](#DropdownButton)
### dropdownButton.itemRenderer(item, index) ⇒ string \| Object
Called for each item when rendering the dropdown.
**Kind**: instance method of [DropdownButton](#DropdownButton)
**Returns**: string \| Object - Formatted & escaped HTML, either as a simple string
or as the 'html' field in an object that also conveys enabled state. Disabled items inherit gray
text color and cannot be selected.
| Param | Type | Description |
| --- | --- | --- |
| item | \* | from items array |
| index | number | in items array |
### dropdownButton.refresh()
Refresh the dropdown list by removing and re-creating all list items.
Call this after deleting/adding any item in the dropdown list.
**Kind**: instance method of [DropdownButton](#DropdownButton)
### dropdownButton.setChecked(index, checked)
Check/Uncheck the list item of the given index.
**Kind**: instance method of [DropdownButton](#DropdownButton)
| Param | Type | Description |
| --- | --- | --- |
| index | number | The index of the list item to be checked or unchecked |
| checked | boolean | True if the list item is to be checked, false to get check mark removed. |
### dropdownButton.showDropdown()
Pops open the dropdown if currently closed. Does nothing if items.length == 0
**Kind**: instance method of [DropdownButton](#DropdownButton)
### dropdownButton.filterDropdown(searchString)
hides all elements in popup that doesn't match the given search string, also shows the search bar in popup
**Kind**: instance method of [DropdownButton](#DropdownButton)
| Param |
| --- |
| searchString |
### dropdownButton.closeDropdown()
Closes the dropdown if currently open
**Kind**: instance method of [DropdownButton](#DropdownButton)
### dropdownButton.toggleDropdown()
Opens the dropdown if closed; closes it if open
**Kind**: instance method of [DropdownButton](#DropdownButton)