wxListEvent(3erl)

πŸ’… wxListEvent (that's the Erlang module btw, bestie)

okay so this page is all about wxListEvent from the Erlang module definitions corner of the wx docs β€” like, it lives in wx 2.2.2.1 and it's brought to you by the wxWidgets team, but we'll get to that at the end πŸŽ€

✨ NAME ✨

wxListEvent β€” literally just the functions for the wxListEvent class. that's it. that's the name section. iconic behavior honestly πŸ‘‘

πŸ¦‹ DESCRIPTION πŸ¦‹

so a list event holds info about events that are associated with wxListCtrl objects. that's the whole vibe check β€” these are the little event packets that show up when stuff happens in a list control ✨

See: wxListCtrl

this class is derived (and can use functions) from: wxNotifyEvent, wxCommandEvent, wxEvent

wxWidgets docs: wxListEvent

🌸 EVENTS 🌸

bestie, listen β€” you use wxEvtHandler:connect/3 with wxListEventType to subscribe to events of this type. that's the move, no cap 🫢

πŸŽ€ DATA TYPES πŸŽ€

wxListEvent() = wx:wx_object()
wxList() =
    #wxList{type = wxListEvent:wxListEventType(),
            code = integer(),
            oldItemIndex = integer(),
            itemIndex = integer(),
            col = integer(),
            pointDrag = {X :: integer(), Y :: integer()}}

okay and here's the big one β€” the event type list, and yes i'm listing every single one of them because they all matter πŸ’–

wxListEventType() =
    command_list_begin_drag | command_list_begin_rdrag |
    command_list_begin_label_edit | command_list_end_label_edit |
    command_list_delete_item | command_list_delete_all_items |
    command_list_key_down | command_list_insert_item |
    command_list_col_click | command_list_col_right_click |
    command_list_col_begin_drag | command_list_col_dragging |
    command_list_col_end_drag | command_list_item_selected |
    command_list_item_deselected | command_list_item_right_click |
    command_list_item_middle_click | command_list_item_activated |
    command_list_item_focused | command_list_cache_hint

πŸ‘‘ EXPORTS πŸ‘‘

⭐ getCacheFrom(This) -> integer()

Types:

This = wxListEvent()

for the EVT_LIST_CACHE_HINT event only, okay? it returns the first item which the list control advises us to cache. very "here's where you should start looking" energy πŸ’…

⭐ getCacheTo(This) -> integer()

Types:

This = wxListEvent()

again, EVT_LIST_CACHE_HINT event only β€” this one returns the last item (inclusive, don't forget that part!) which the list control advises us to cache 🧚

⭐ getKeyCode(This) -> integer()

Types:

This = wxListEvent()

key code, but only if the event is a keypress event. if it's not, well… it's not 😭

⭐ getIndex(This) -> integer()

Types:

This = wxListEvent()

the item index. short and sweet, we love a low-effort icon ✨

⭐ getColumn(This) -> integer()

Types:

This = wxListEvent()

the column position β€” and heads up, it is only used with COL events πŸ™ˆ

for the column dragging events, it's the column to the left of the divider being dragged. for the column click events it may be -1 if the user clicked in the list control header outside any column. yes, -1. that's the "you clicked in the void" number πŸ’€

⭐ getPoint(This) -> {X :: integer(), Y :: integer()}

Types:

This = wxListEvent()

the position of the mouse pointer, but only if the event is a drag event. very demure, very mouse-aware πŸ“

⭐ getLabel(This) -> unicode:charlist()

Types:

This = wxListEvent()

the (new) item label β€” and this one's specifically for the EVT_LIST_END_LABEL_EDIT event πŸ’–

⭐ getText(This) -> unicode:charlist()

Types:

This = wxListEvent()

the text. that's it. that's the description. ngl i respect the brevity 🌈

⭐ getImage(This) -> integer()

Types:

This = wxListEvent()

the image πŸ¦‹

⭐ getData(This) -> integer()

Types:

This = wxListEvent()

the data ✨

⭐ getMask(This) -> integer()

Types:

This = wxListEvent()

the mask πŸŽ€

⭐ getItem(This) -> wxListItem:wxListItem()

Types:

This = wxListEvent()

an item object β€” used by some events. "some events" bestie, they really said figure it out 😭

See also wxListCtrl:setItem/5.

⭐ isEditCancelled(This) -> boolean()

Types:

This = wxListEvent()

okay this one actually needs a whole paragraph, so listen up πŸ’…

this method only makes sense for the EVT_LIST_END_LABEL_EDIT message, and it returns true if the label editing has been cancelled by the user.

and here's the little gotcha the docs are being shady about: getLabel/1 returns an empty string in this case, but it doesn't allow the application to distinguish between really cancelling the edit and the admittedly rare case when the user wants to rename it to an empty string. like β€” empty string could mean "they cancelled" OR "they genuinely wanted it blank" and getLabel/1 can't tell you which 😭 that's why this function exists. use it. periodt πŸ”₯


fr fr, that's the whole page β€” nothing skipped, nothing merged, every option and type exactly where it belongs 🫢

✨ this has been wxListEvent(3erl) from the wx 2.2.2.1 docs, dated to the wx 2.2.2.1 release and signed off by the wxWidgets team β€” mwah, thanks for reading, ily, go cache some list items responsibly πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from