wComboBox

A combobox is like a combination of an edit control and a listbox.

Notice: a combobox may recieve events propagated from its child text control. (wEvent_Text, wEvent_TextUpdate, wEvent_TextMaxlen etc.) In these case, event.window should be the child text control, not combobox itself.

Appearance:
Superclass:wControl
Styles:
StylesDescription
wCbSimpleCreates a combobox with a permanently displayed list.
wCbDropDownCreates a combobox with a drop-down list.
wCbReadOnlyAllows the user to choose from the list but doesn't allow to enter a value.
wCbSortSorts the entries in the list alphabetically.
wCbNeededScrollOnly create a vertical scrollbar if needed.
wCbAlwaysScrollAlways show a vertical scrollbar.
wCbAutoHScrollAutomatically scrolls the text in an edit control to the right when the user types a character at the end of the line.
Events:wCommandEvent
wCommandEventDescription
wEvent_ComboBoxWhen an item on the list is selected, calling getValue() returns the new value of selection.
wEvent_ComboBoxCloseUpWhen the list box of the combo box disappears.
wEvent_ComboBoxDropDownWhen the list box part of the combo box is shown.
wEvent_TextWhen the text changes.
wEvent_TextUpdateWhen the control is about to redraw itself.
wEvent_TextMaxlenWhen the user tries to enter more text into the control than the limit.
wEvent_TextEnterWhen pressing Enter key.
wEvent_CommandSetFocusWhen the control receives the keyboard focus.
wEvent_CommandKillFocusWhen the control loses the keyboard focus.
wEvent_CommandLeftDoubleClickDouble-clicked the left mouse button within the control.

Consts

wCbSimple = 0x00000001
wCbDropDown = 0x00000002
wCbReadOnly = 0x00000003
wCbSort = 0x00000100
wCbNeededScroll = 0x00200000
wCbAlwaysScroll = 2099200
wCbAutoHScroll = 0x00000040

Procs

proc getCount(self: wComboBox): int {...}{.validate, property, inline, raises: [], tags: [].}
Returns the number of items in the control.
proc len(self: wComboBox): int {...}{.validate, inline, raises: [], tags: [].}
Returns the number of items in the control.
proc getText(self: wComboBox; index: int): string {...}{.raises: [], tags: [].}
Returns the text of the item with the given index.
proc `[]`(self: wComboBox; index: int): string {...}{.validate, inline, raises: [], tags: [].}
Returns the text of the item with the given index. Raise error if index out of bounds.
proc insert(self: wComboBox; pos: int; text: string) {...}{.validate, inline, raises: [],
    tags: [].}
Inserts the given string before the specified position. Notice that the inserted item won't be sorted even the list box has wCbSort style. If pos is -1, the string is added to the end of the list.
proc insert(self: wComboBox; pos: int; list: openArray[string]) {...}{.validate, inline,
    raises: [], tags: [].}
Inserts multiple strings in the same time.
proc append(self: wComboBox; text: string) {...}{.validate, inline, raises: [], tags: [].}
Appends the given string to the end. If the combo box has the wCbSort style, the string is inserted into the list and the list is sorted.
proc append(self: wComboBox; list: openArray[string]) {...}{.validate, inline, raises: [],
    tags: [].}
Appends multiple strings in the same time.
proc delete(self: wComboBox; index: int) {...}{.validate, inline, raises: [], tags: [].}
Delete a string in the combo box.
proc delete(self: wComboBox; text: string) {...}{.validate, inline, raises: [], tags: [].}
Search and delete the specified string in the combo box.
proc clear(self: wComboBox) {...}{.validate, inline, raises: [], tags: [].}
Remove all items from a combo box.
proc findText(self: wComboBox; text: string): int {...}{.validate, inline, raises: [], tags: [].}
Finds an item whose label matches the given text.
proc getSelection(self: wComboBox): int {...}{.validate, property, inline, raises: [],
                                      tags: [].}
Returns the index of the selected item or wNotFound(-1) if no item is selected.
proc select(self: wComboBox; index: int) {...}{.validate, inline, raises: [], tags: [].}
Sets the selection to the given index or removes the selection entirely if index == wNotFound(-1).
proc setSelection(self: wComboBox; index: int) {...}{.validate, property, inline, raises: [],
    tags: [].}
The same as select().
proc setText(self: wComboBox; index: int; text: string) {...}{.validate, property, raises: [],
    tags: [].}
Changes the text of the specified combobox item.
proc changeValue(self: wComboBox; text: string) {...}{.validate, property, raises: [],
    tags: [].}
Sets the text for the combobox text field. Notice that this proc won't generate wEvent_Text event.
proc setValue(self: wComboBox; text: string) {...}{.validate, property, inline, raises: [],
    tags: [].}
Sets the text for the combobox text field. Notice that this proc will generate wEvent_Text event.
proc getValue(self: wComboBox): string {...}{.validate, property, inline, raises: [], tags: [].}
Gets the text for the combobox text field.
proc isListEmpty(self: wComboBox): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the list of combobox choices is empty.
proc isTextEmpty(self: wComboBox): bool {...}{.validate, inline, raises: [], tags: [].}
Returns true if the text of the combobox is empty.
proc popup(self: wComboBox) {...}{.validate, inline, raises: [], tags: [].}
Shows the list box portion of the combo box.
proc dismiss(self: wComboBox) {...}{.validate, inline, raises: [], tags: [].}
Hides the list box portion of the combo box.
proc getEditControl(self: wComboBox): wTextCtrl {...}{.validate, property, inline,
    raises: [], tags: [].}
Returns the text control part of this combobox, or nil if no such control.
proc getTextCtrl(self: wComboBox): wTextCtrl {...}{.validate, property, inline, raises: [],
    tags: [].}
Returns the text control part of this combobox, or nil if no such control. The same as getEditControl().
proc getListControl(self: wComboBox): wWindow {...}{.validate, property, inline, raises: [],
    tags: [].}
Returns the list control part of this combobox, or nil if no such control. Notice that the result is wWindow for event handler only, not a wListBox.
proc final(self: wComboBox) {...}{.raises: [], tags: [].}
Default finalizer for wComboBox.
proc init(self: wComboBox; parent: wWindow; id = wDefaultID; value: string = "";
         pos = wDefaultPoint; size = wDefaultSize; choices: openArray[string] = [];
         style: wStyle = wCbDropDown) {...}{.validate, raises: [], tags: [].}
Initializer.
proc ComboBox(parent: wWindow; id = wDefaultID; value: string = ""; pos = wDefaultPoint;
             size = wDefaultSize; choices: openArray[string] = [];
             style: wStyle = wCbDropDown): wComboBox {...}{.inline, discardable, raises: [],
    tags: [].}
Constructor, creating and showing a combobox.

Methods

method getDefaultSize(self: wComboBox): wSize {...}{.raises: [], tags: [].}
Returns the default size for the control.
method getBestSize(self: wComboBox): wSize {...}{.raises: [], tags: [].}
Returns the best acceptable minimal size for the control.

Iterators

iterator items(self: wComboBox): string {...}{.validate, inline, raises: [], tags: [].}
Iterate each item in this combo box. Iterates over each item in this combo box. Yields (index, [index]) pairs.