wxRuby Documentation Home

Wx::ComboBox

A combobox is like a combination of an edit control and a listbox. It can be
displayed as static list with editable or read-only text field; or a drop-down list with
text field; or a drop-down list without a text field.

A combobox permits a single selection only. Combobox items are numbered from zero.

Derived from

ControlWithItems

Control

Window

EvtHandler

Object

Window styles

CB_SIMPLE Creates a combobox with a permanently displayed list. Windows only.
CB_DROPDOWN Creates a combobox with a drop-down list.
CB_READONLY Same as CB_DROPDOWN but only thestrings specified as the combobox choices can be selected, it is impossible toselect (even from a program) a string which is not in the choices list.
CB_SORT Sorts the entries in the list alphabetically.
TE_PROCESS_ENTER The control will generatethe event EVT_COMMAND_TEXT_ENTER (otherwise pressing Enter keyis either processed internally by the control or used for navigation betweendialog controls). Windows only.

See also window styles overview.

Event handling

evt_combobox(id) { | event | … } Process a EVT_COMMAND_COMBOBOX_SELECTED event,when an item on the list is selected. Note that calling"get_value":#ComboBox_getvalue returns the new value of selection.
evt_text(id) { | event | … } Process a EVT_COMMAND_TEXT_UPDATED event,when the combobox text changes.
evt_text_enter(id) { | event | … } Process a EVT_COMMAND_TEXT_ENTER event,when is pressed in the combobox.

See also

ListBox, TextCtrl, Choice,
CommandEvent

Methods

ComboBox.new

ComboBox.new(%(arg-type)Window% parent, Integer id, String value, Point pos, Size size, Array choices, Integer style = 0, Validator validator = DEFAULT_VALIDATOR, String name = “comboBox”)

Constructor, creating and showing a combobox.

Parameters

See also

ComboBox#create, Validator

ComboBox#create

Boolean create(%(arg-type)Window% parent, Integer id, String value, Point pos, Size size, ArrayString choices, Integer style = 0, Validator validator = DEFAULT_VALIDATOR, String name = “comboBox”)

Creates the combobox for two-step construction. Derived classes should call or replace this function. See ComboBox.new for further details.

ComboBox#can_copy

Boolean can_copy()

Returns true if the combobox is editable and there is a text selection
to copy to the clipboard.

Only available on Windows.

ComboBox#can_cut

Boolean can_cut()

Returns true if the combobox is editable and there is a text selection to copy to the clipboard.
Only available on Windows.

ComboBox#can_paste

Boolean can_paste()

Returns true if the combobox is editable and there is text on the clipboard that can be pasted into the
text field. Only available on Windows.

ComboBox#can_redo

Boolean can_redo()

Returns true if the combobox is editable and the last undo can be redone.
Only available on Windows.

ComboBox#can_undo

Boolean can_undo()

Returns true if the combobox is editable and the last edit can be undone.
Only available on Windows.

ComboBox#copy

copy()

Copies the selected text to the clipboard.

ComboBox#cut

cut()

Copies the selected text to the clipboard and removes the selection.

ComboBox#get_current_selection

Integer get_current_selection()

This function does the same things as
Choice#get_current_selection and
returns the item currently selected in the dropdown list if it’s open or the
same thing as get_selection otherwise.

ComboBox#get_insertion_point

Integer get_insertion_point()

Returns the insertion point for the combobox’s text field.

Note: Under MSW, this function always returns 0 if the combobox
doesn’t have the focus.

ComboBox#get_last_position

TextPos get_last_position()

Returns the last position in the combobox text field.

ComboBox#get_text_selection_range

Integer from, Integer to = get_text_selection_range()

This is the same as
TextCtrl#get_selection
for the text control which is part of the combobox, returning the
start and end position of the text selection.

Currently this method is only implemented in MSW and GTK.

ComboBox#get_value

String get_value()

Returns the current value in the combobox text field.

ComboBox#paste

paste()

Pastes text from the clipboard to the text field.

ComboBox#redo

redo()

Redoes the last undo in the text field. Windows only.

ComboBox#replace

replace(%(arg-type)Integer% from, Integer to, String text)

Replaces the text between two positions with the given text, in the combobox text field.

Parameters

ComboBox#remove

remove(%(arg-type)Integer% from, Integer to)

Removes the text between the two positions in the combobox text field.

Parameters

ComboBox#set_insertion_point

set_insertion_point(%(arg-type)Integer% pos)

Sets the insertion point in the combobox text field.

Parameters

ComboBox#set_insertion_point_end

set_insertion_point_end()

Sets the insertion point at the end of the combobox text field.

ComboBox#set_text_selection_range

set_text_selection_range(%(arg-type)Integer% from, Integer to)

Selects the text between the two positions, in the combobox text field.

Parameters

ComboBox#set_value

set_value(%(arg-type)String% text)

Sets the text for the combobox text field.

NB: For a combobox with CB_READONLY style the string must be in
the combobox choices list, otherwise the call to SetValue() is ignored.

Parameters

ComboBox#undo

undo()

Undoes the last edit in the text field. Windows only.

[This page automatically generated from the Textile source at 2023-06-13 21:31:37 +0000]