DComboBox
Description
A field with multiple selectable values.
Parent
Derives methods, etc not listed on this page from DButton.
Implements
Implements or overrides the following hooks/methods. If you want to override these, you probably want to call the original function too.
Events
DComboBox:OnMenuOpened( Panel menu )
Called when the player opens the dropdown menu. For Override
Methods
number DComboBox:AddChoice( string value, any data = nil, boolean select = false, string icon = nil )
Adds a choice to the combo box.
DComboBox:AddSpacer()
Adds a spacer below the currently last item in the drop down. Recommended to use with DComboBox:SetSortItems set to false.
DComboBox:CheckConVarChanges()
This is used internally - although you're able to use it you probably shouldn't.
Ran every frame to update the value of this panel to the value of the associated convar. See Panel:SetConvar.
Selects a combo box option by its index and changes the text displayed at the top of the combo box.
DComboBox:ChooseOptionID( number index )
Selects an option within a combo box based on its table index.
DComboBox:Clear()
Clears the combo box's text value, choices, and data values.
DComboBox:CloseMenu()
Closes the combo box menu. Called when the combo box is clicked while open.
Returns an option's data based on the given index.
Returns an option's text based on the given index.
Returns an option's text based on the given data.
Returns the currently selected option's text and data
number DComboBox:GetSelectedID()
Returns the index (ID) of the currently selected option.
boolean DComboBox:GetSortItems()
An AccessorFunc that returns an whether the items in the dropdown will be alphabetically sorted or not.
See DComboBox:SetSortItems.
boolean DComboBox:IsMenuOpen()
Returns whether or not the combo box's menu is opened.
DComboBox:OpenMenu()
Opens the combo box drop down menu. Called when the combo box is clicked.
Removes a choice added with DComboBox:AddChoice
DComboBox:SetSortItems( boolean sort )
An AccessorFunc that sets whether or not the items should be sorted alphabetically in the dropdown menu of the DComboBox. If set to false, items will appear in the order they were added by DComboBox:AddChoice calls.
This is enabled by default.
Example
Creates a Combo Box.
Output:
option B was selected at index 2
Example
Create a Combo Box with all players.
preview from derma_controls
concmd