ComboBox

A native Win32 combo box of selectable string items.

Constructors

this
this(Widget parent, ComboBoxStyle style)

Create a combo box as a child of parent.

Members

Functions

addItem
int addItem(string text)

Append text to the end of the list; returns the new item's index.

clear
void clear()

Remove all items (and release any retained item data; see setItemData).

getItemCount
int getItemCount()

Return the number of items in the list.

getItemData
void* getItemData(int index)

Return the opaque pointer previously stored for the item at index.

getItemText
string getItemText(int index)

Return the text of the item at index, or "" if it has none.

getPreferredSize
Size getPreferredSize()

A sensible default size for a combo box.

getSelectedIndex
int getSelectedIndex()

Return the selected item's index, or -1 (CB_ERR) if none is selected.

insertItem
void insertItem(int index, string text)

Insert text at index, shifting later items down.

processCommand
bool processCommand(ushort code)

Route a WM_COMMAND notification. Fires onSelectionChanged on CBN_SELCHANGE and onTextChanged on CBN_EDITCHANGE (the latter is only meaningful for the editable styles).

processSubclassed
bool processSubclassed(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result)

Auto-select the first item when a non-editable drop-down list receives focus, so a screen reader announces an item as the user tabs in. Never consumes the focus message.

removeItem
void removeItem(int index)

Remove the item at index.

setItemData
void setItemData(int index, void* data)

Associate an opaque data pointer with the item at index.

setSelectedIndex
void setSelectedIndex(int index)

Select the item at index (pass -1 to clear the selection).

Variables

onSelectionChanged
Event!(int) onSelectionChanged;

Fired when the selection changes; carries the new selected index.

onTextChanged
Event!(string) onTextChanged;

Fired when the editable text changes; carries the new text.

Inherited Members

From Control

controlId
int controlId()

The control's command identifier (the hMenu child id at creation).

setText
void setText(string text)

Set the control's text.

getText
string getText()

Get the control's text.

setFont
void setFont(HFONT font)

Assign a font to the control and request a repaint.

getPreferredSize
Size getPreferredSize()

A reasonable default preferred size; override per control type.

processCommand
bool processCommand(ushort notificationCode)

Handle a WM_COMMAND notification routed from the parent.

processNotify
bool processNotify(NMHDR* header)

Handle a WM_NOTIFY notification routed from the parent. Return true if it was handled. The default does nothing.

subclass
void subclass()

Install a subclass window procedure so the control can intercept its own messages (for example, swallowing the Enter key in a text field). Idempotent. Subclasses override processSubclassed to do the work.

processSubclassed
bool processSubclassed(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT result)

Intercept a message while subclassed. Set result and return true to consume the message; return false to let default processing continue.

Meta