wxChoice — wx v2.4.3

Search documentation of wx

# View Source wxChoice (wx v2.4.3)

A choice item is used to select one of a list of strings.

Unlike a `wxListBox`, only the selection is visible until the user pulls down the menu of choices.

## Styles

This class supports the following styles:

- wxCB_SORT: Sorts the entries alphabetically.

See:

- `wxListBox`

- `wxComboBox`

- `wxCommandEvent`

This class is derived, and can use functions, from:

- `wxControlWithItems`

- `wxControl`

- `wxWindow`

- `wxEvtHandler`

wxWidgets docs: wxChoice

## Events

Event types emitted from this class:

- `command_choice_selected`

# Summary

## Types

wxChoice()

## Functions

create(This, Parent, Id, Pos, Size, Choices)

Equivalent to `create(This, Parent, Id, Pos, Size, Choices, [])`.

create/7
delete(This, N)

Deletes an item from the control.

destroy(This)

Destroys the object

getColumns(This)

Gets the number of columns in this choice item.

new()

Default constructor.

new(Parent, Id)

Equivalent to `new(Parent, Id, [])`.

new/3

Constructor, creating and showing a choice.

setColumns(This)

Equivalent to `setColumns(This, [])`.

setColumns/2

Sets the number of columns in this choice item.

# Types

Link to this type

# wxChoice()

View Source

    -type wxChoice() :: wx:wx_object().

# Functions

Link to this function

# create(This, Parent, Id, Pos, Size, Choices)

View Source

    -spec create(This, Parent, Id, Pos, Size, Choices) -> boolean()
                    when
                        This :: wxChoice(),
                        Parent :: wxWindow:wxWindow(),
                        Id :: integer(),
                        Pos :: {X :: integer(), Y :: integer()},
                        Size :: {W :: integer(), H :: integer()},
                        Choices :: [unicode:chardata()].

Equivalent to `create(This, Parent, Id, Pos, Size, Choices, [])`.

Link to this function

# create/7

View Source

    -spec create(This, Parent, Id, Pos, Size, Choices, [Option]) -> boolean()
                    when
                        This :: wxChoice(),
                        Parent :: wxWindow:wxWindow(),
                        Id :: integer(),
                        Pos :: {X :: integer(), Y :: integer()},
                        Size :: {W :: integer(), H :: integer()},
                        Choices :: [unicode:chardata()],
                        Option :: {style, integer()} | {validator, wx:wx_object()}.

Link to this function

# delete(This, N)

View Source

    -spec delete(This, N) -> ok when This :: wxChoice(), N :: integer().

Deletes an item from the control.

The client data associated with the item will be also deleted if it is owned by the control. Note that it is an error (signalled by an assert failure in debug builds) to remove an item with the index negative or greater or equal than the number of items in the control.

If there is a currently selected item below the item being deleted, i.e. if `wxControlWithItems:getSelection/1` returns a valid index greater than or equal to `n`, the selection is invalidated when this function is called. However if the selected item appears before the item being deleted, the selection is preserved unchanged.

See: `wxControlWithItems:clear/1`

Link to this function

# destroy(This)

View Source

    -spec destroy(This :: wxChoice()) -> ok.

Destroys the object

Link to this function

# getColumns(This)

View Source

    -spec getColumns(This) -> integer() when This :: wxChoice().

Gets the number of columns in this choice item.

Remark: This is implemented for GTK and Motif only and always returns 1 for the other platforms.

Link to this function

# new()

View Source

    -spec new() -> wxChoice().

Default constructor.

See: `create/7`

Link to this function

# new(Parent, Id)

View Source

    -spec new(Parent, Id) -> wxChoice() when Parent :: wxWindow:wxWindow(), Id :: integer().

Equivalent to `new(Parent, Id, [])`.

Link to this function

# new/3

View Source

    -spec new(Parent, Id, [Option]) -> wxChoice()
                 when
                     Parent :: wxWindow:wxWindow(),
                     Id :: integer(),
                     Option ::
                         {pos, {X :: integer(), Y :: integer()}} |
                         {size, {W :: integer(), H :: integer()}} |
                         {choices, [unicode:chardata()]} |
                         {style, integer()} |
                         {validator, wx:wx_object()}.

Constructor, creating and showing a choice.

See: `create/7`

Link to this function

# setColumns(This)

View Source

    -spec setColumns(This) -> ok when This :: wxChoice().

Equivalent to `setColumns(This, [])`.

Link to this function

# setColumns/2

View Source

    -spec setColumns(This, [Option]) -> ok when This :: wxChoice(), Option :: {n, integer()}.

Sets the number of columns in this choice item.

Remark: This is implemented for GTK and Motif only and doesn’t do anything under other platforms.