wxListBox(3)
π wxListBox β the Erlang module, but make it cute π
okay bestie, come closer. This is wxListBox(3) from the Erlang module definitions, and yes the manual name is right there in the title because we keep it π―.
β¨ NAME β¨
wxListBox β a listbox is used to select one or more of a list of strings. that's it, that's the whole vibe π
πΈ DESCRIPTION πΈ
So basically: the strings get displayed in a scrolling box, and whichever string(s) you selected are marked in reverse video (iconic highlighting behavior, no notes π ). A listbox can be single selection β meaning if you pick an item, the previous selection gets yeeted β or multiple selection β meaning clicking an item toggles it on or off independently of all the other selections. choose your fighter π«Ά
List box elements are numbered from zero, and while the maximal number of elements is unlimited, it is usually better to use a virtual control, not requiring you to add all the items to it at once β think wxDataViewCtrl (not implemented in wx) or wxListCtrl with wxLC_VIRTUAL style β once more than a few hundred items need to be displayed. why?? because this control is not optimized, neither from a performance nor from a user interface point of view, for large numbers of items. she's cute but she's not built for that many π₯²
not me reminding you: the list box doesn't support control characters other than TAB. periodt.
π¦ Styles π¦
This class supports the following styles, and yes we're listing every single one:
wxLB_SINGLEβ Single-selection list.wxLB_MULTIPLEβ Multiple-selection list: the user can toggle multiple items on and off. This is the same aswxLB_EXTENDEDin wxGTK2 port.wxLB_EXTENDEDβ Extended-selection list: the user can extend the selection by using SHIFT or CTRL keys together with the cursor movement keys or the mouse.wxLB_HSCROLLβ Create horizontal scrollbar if contents are too wide (Windows only).wxLB_ALWAYS_SBβ Always show a vertical scrollbar.wxLB_NEEDED_SBβ Only create a vertical scrollbar if needed.wxLB_NO_SBβ Don't create vertical scrollbar (wxMSW and wxGTK only).wxLB_SORTβ The listbox contents are sorted in alphabetical order. Note thatwxLB_SINGLE,wxLB_MULTIPLEandwxLB_EXTENDEDstyles are mutually exclusive and you can specify at most one of them (single selection is the default). See alsooverview_windowstyles.
See:
wxChoicewxComboBoxwxListCtrlwxCommandEvent
This class is derived, and can use functions, from:
wxControlWithItemswxControlwxWindowwxEvtHandler
wxWidgets docs: wxListBox β iykyk π§
π₯ Events π₯
Event types emitted from this class:
command_listbox_selectedcommand_listbox_doubleclicked
π DATA TYPES π
wxListBox() :: wx:wx_object().
look at her. an object. main character energy fr fr π
β FUNCTIONS β
create(This, Parent, Id, Pos, Size, Choices, [Option]) -> boolean()
create(This, Parent, Id, Pos, Size, Choices, [Option]) -> boolean()
when
This :: wxListBox(),
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()}.
deselect(This, N) -> okwhenThis :: wxListBox(),N :: integer().
Deselects an item in the list box.
Remark: this applies to multiple selection listboxes only. don't come for me when it doesn't work on a single-selection one, the manual literally said so π
destroy(This :: wxListBox()) -> ok.
Destroys the object. goodbye bestie, it's giving exit stage left π
getSelections(This) -> Resultwhen
Result :: {Res :: integer(), Selections :: [integer()]},
This :: wxListBox().
Fill an array of ints with the positions of the currently selected items.
Return: the number of selections.
Remark: use this with a multiple selection listbox.
See:
wxControlWithItems:getSelection/1wxControlWithItems:getStringSelection/1wxControlWithItems:setSelection/2
hitTest(This, Point) -> integer()when
This :: wxListBox(),
Point :: {X :: integer(), Y :: integer()}.
Returns the item located at point, or wxNOT_FOUND if there is no item located at point.
It is currently implemented for wxMSW, wxMac and wxGTK2 ports.
Return: item located at point, or wxNOT_FOUND if unimplemented or the item does not exist.
Since: 2.7.0
hitTest(This, X, Y) -> integer()when
This :: wxListBox(), X :: integer(), Y :: integer().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. same energy, different signature π«Ά
insertItems(This, Items, Pos) -> okwhen
This :: wxListBox(),
Items :: [unicode:chardata()],
Pos :: integer().
Insert the given number of strings before the specified position. slide in, no cap π
isSelected(This, N) -> boolean()whenThis :: wxListBox(),N :: integer().
Determines whether an item is selected.
Return: true if the given item is selected, false otherwise.
new() -> wxListBox().
Default constructor. the blank canvas. the pre-glow-up era β¨
new(Parent, Id, [Option]) -> wxListBox()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 list box.
See the other new/3 constructor; the only difference is that this overload takes a wxArrayString (not implemented in wx) instead of a pointer to an array of wxString (not implemented in wx).
set(This, Items) -> okwhenThis :: wxListBox(),Items :: [unicode:chardata()].
Replaces the current control contents with the given items.
Notice that calling this method is usually much faster than appending them one by one if you need to add a lot of items. lowkey a speedrun strats situation π₯
setFirstItem(This, N) -> okwhenThis :: wxListBox(),N :: integer();(This, String) -> okwhen
This :: wxListBox(),
String :: unicode:chardata().
Set the specified item to be the first visible item.
β οΈ bestie heads up:wxLB_SINGLE,wxLB_MULTIPLEandwxLB_EXTENDEDare mutually exclusive β pick at most one or the vibe check fails. and remember this control is not optimized for huge lists, so go virtual when it gets big. π
and that's the whole page, you're officially a wxListBox scholar now, I'm so proud π₯Ήπ«Ά
this lil manual moment was brought to you by Ericsson AB for wx 2.6, dated with the classic wxListBox(3) β mwah π stay slaying, and don't forget to destroy your objects ππ
π¦ where this page comes from
- ubuntu stonking: erlang-doc 1:29.0.6+dfsg-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms