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 listbox of the combobox disappears.
wEvent_ComboBoxDropDownWhen the listbox part of the combobox 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 {...}{.inline, raises: [], tags: [].}
Returns the number of items in the control.
proc len(self: wComboBox): int {...}{.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 {...}{.inline, raises: [IndexDefect], 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) {...}{.inline, raises: [], tags: [].}
Inserts the given string before the specified position. Notice that the inserted item won't be sorted even the listbox 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]) {...}{.inline, raises: [],
    tags: [].}
Inserts multiple strings in the same time.
proc append(self: wComboBox; text: string) {...}{.inline, raises: [], tags: [].}
Appends the given string to the end. If the combobox has the wCbSort style, the string is inserted into the list and the list is sorted.
proc append(self: wComboBox; list: openArray[string]) {...}{.inline, raises: [], tags: [].}
Appends multiple strings in the same time.
proc delete(self: wComboBox; index: int) {...}{.inline, raises: [], tags: [].}
Delete a string in the combobox.
proc delete(self: wComboBox; text: string) {...}{.inline, raises: [], tags: [].}
Search and delete the specified string in the combobox.
proc clear(self: wComboBox) {...}{.inline, raises: [], tags: [].}
Remove all items from a combobox.
proc findText(self: wComboBox; text: string): int {...}{.inline, raises: [], tags: [].}
Finds an item whose label matches the given text.
proc getSelection(self: wComboBox): int {...}{.inline, raises: [], tags: [].}
Returns the index of the selected item or wNotFound(-1) if no item is selected.
proc select(self: wComboBox; index: int) {...}{.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) {...}{.inline, raises: [], tags: [].}
The same as select().
proc setText(self: wComboBox; index: int; text: string) {...}{.raises: [], tags: [].}
Changes the text of the specified combobox item.
proc changeValue(self: wComboBox; text: string) {...}{.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) {...}{.inline, raises: [Exception],
    tags: [RootEffect].}
Sets the text for the combobox text field. Notice that this proc will generate wEvent_Text event.
proc getValue(self: wComboBox): string {...}{.inline, raises: [], tags: [].}
Gets the text for the combobox text field.
proc isListEmpty(self: wComboBox): bool {...}{.inline, raises: [], tags: [].}
Returns true if the list of combobox choices is empty.
proc isTextEmpty(self: wComboBox): bool {...}{.inline, raises: [], tags: [].}
Returns true if the text of the combobox is empty.
proc isPopup(self: wComboBox): bool {...}{.inline, raises: [], tags: [].}
Returns whether or not the listbox is popup.
proc popup(self: wComboBox) {...}{.inline, raises: [], tags: [].}
Shows the listbox portion of the combobox.
proc dismiss(self: wComboBox) {...}{.inline, raises: [], tags: [].}
Hides the listbox portion of the combobox.
proc getEditControl(self: wComboBox): wTextCtrl {...}{.inline, raises: [], tags: [].}
Returns the text control part of this combobox, or nil if no such control.
proc getTextCtrl(self: wComboBox): wTextCtrl {...}{.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): wListBox {...}{.inline, raises: [], tags: [].}
Returns the list control part of this combobox, or nil if no such control.
proc init(self: wComboBox; parent: wWindow; id = wDefaultID; value: string = "";
         pos = wDefaultPoint; size = wDefaultSize; choices: openArray[string] = [];
         style: wStyle = wCbDropDown) {...}{.raises: [wNilAccess, wWindowError,
    wCursorError, wBrushError, Exception, IndexDefect, wFontError, wError],
                                    tags: [RootEffect].}
Initializes a combobox.
proc ComboBox(parent: wWindow; id = wDefaultID; value: string = ""; pos = wDefaultPoint;
             size = wDefaultSize; choices: openArray[string] = [];
             style: wStyle = wCbDropDown): wComboBox {...}{.inline, discardable, raises: [
    wNilAccess, wWindowError, wCursorError, wBrushError, Exception, IndexDefect,
    wFontError, wError], tags: [RootEffect].}
Constructor.

Methods

method getDefaultSize(self: wComboBox): wSize {...}{.inline, raises: [Exception],
    tags: [RootEffect].}
Returns the default size for the control.
method getBestSize(self: wComboBox): wSize {...}{.inline, raises: [Exception],
    tags: [RootEffect].}
Returns the best acceptable minimal size for the control.
method release(self: wComboBox) {...}{.raises: [], tags: [RootEffect].}
Release all the resources during destroying. Used internally.

Iterators

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