Skip to main content

DropdownButton

Import :

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

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

ParamTypeDefaultDescription
labelstringThe label to display on the button.
itemsArray.<*>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]functionOptional 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]ObjectAdditional options for the dropdown.
[options.enableFilter]booleanfalseSet to true to enable filtering by typing.
[options.cssClasses]stringA space-separated list of CSS classes to apply to the button.
[options.customFilter]functionOptional. 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.

Items in dropdown list - may be changed any time dropdown isn't open

Kind: instance property of DropdownButton

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

The clickable button. Available as soon as the DropdownButton is constructed.

Kind: instance property of DropdownButton

The dropdown element. Only non-null while open.

Kind: instance property of DropdownButton

Extra CSS class(es) to apply to $dropdown

Kind: instance property of DropdownButton

Update the button label.

Kind: instance method of DropdownButton

ParamType
labelstring

returns true if the dropdown is open

Kind: instance method of DropdownButton

Called for each item when rendering the dropdown.

Kind: instance method of 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.

ParamTypeDescription
item*from items array
indexnumberin items array

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

Check/Uncheck the list item of the given index.

Kind: instance method of DropdownButton

ParamTypeDescription
indexnumberThe index of the list item to be checked or unchecked
checkedbooleanTrue if the list item is to be checked, false to get check mark removed.

Pops open the dropdown if currently closed. Does nothing if items.length == 0

Kind: instance method of DropdownButton

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

Param
searchString

Closes the dropdown if currently open

Kind: instance method of DropdownButton

Opens the dropdown if closed; closes it if open

Kind: instance method of DropdownButton