Combo and Dropdown
Use combo and dropdown controls when the user must choose from known options.
Main helpers
| Helper | Use it for |
|---|---|
Mui::ComboBox |
A value field with options |
Mui::LabeledCombo |
Label plus combo box |
Mui::Dropdown |
Button/menu-style option picker |
Mui::ListBox |
Simple visible list of options |
ComboBox
The array-backed selected-index overload is the easiest starting point.
string modes[];
ArrayResize(modes,3);
modes[0]="Manual";
modes[1]="Semi-auto";
modes[2]="Disabled";
MuiComboBoxHost *combo=Mui::ComboBox(parent,modes,0,260.0,0.0);
When items[] is not empty, the selected index is clamped to the valid range.
LabeledCombo
For form panels, use LabeledCombo.
MuiLabeledCombo mode=Mui::LabeledCombo(
section.body,
"Mode",
modes,
0,
0.0,
0.0,
"Select how this panel should behave."
);
ComboBox with handler
Use a combo handler when your EA should respond immediately to a user choice.
class ModePickHandler : public MuiComboItemHandler
{
public:
virtual void OnComboItem(const int index,const string text)
{
Print("Selected mode: ",text);
}
};
MuiComboBoxHost *combo=Mui::ComboBox(parent,modes,new ModePickHandler(),"Manual",260.0,0.0);
Dropdown
Use a dropdown when you want a menu-style choice.
string actions[];
ArrayResize(actions,3);
actions[0]="Refresh";
actions[1]="Export";
actions[2]="Reset";
MuiDropdown *dd=Mui::Dropdown(parent,"Actions",actions,new ActionMenuHandler(),220.0,0.0);
Dropdown menu handling uses MuiMenuItemHandler.
ComboBox vs Dropdown
| Need | Use |
|---|---|
| A field-like value selector | ComboBox |
| A labelled form row | LabeledCombo |
| A menu button with actions | Dropdown |
| A visible list of options | ListBox |
Width and height
| Argument | Behaviour |
|---|---|
width 0.0 |
Use default control width |
height 0.0 |
Use theme combo/dropdown height |
| selected index outside bounds | Clamped when items exist |
Common mistakes
Using free text for fixed options
Use combo/dropdown for known modes or presets.
Expecting empty items to select index zero
If the item array is empty, there is nothing to select.
Using Dropdown for settings that should remain visible
If the chosen value should be visible as a setting, a combo is often clearer.
Related pages
- MuiComboBoxHost —
MUI_EVENT_SELECTION_CHANGED Mui::LabeledCombo- MuiDropdown
- Event Bus
- Labeled inputs
- Combo, List, Table, and Tabs
- Drawer, dialogs, and menus