wxGridEvent(3erl)

πŸ’… wxGridEvent πŸ’…

Okay bestie, so this is the Erlang module page for wxGridEvent β€” the Functions for wxGridEvent class situation, straight out of the Erlang Module Definition manual. Pull up a chair, we're doing grid events today and honestly? Iconic behavior only. πŸŽ€


✨ DESCRIPTION ✨

So this event class literally contains the info about all the various grid events. It's giving "notes app full of gossip" but make it a class. πŸ’…

Okay but real talk, bestie, listen β€” notice that all grid event table macros come in two versions, and this is the part where people get caught out:

  • EVT_GRID_XXX
  • EVT_GRID_CMD_XXX

The only difference between the two is that the first one doesn't allow you to specify the grid window identifier, so it takes a single parameter: the event handler. And here's the catch β€” it is not suitable if there is more than one grid control in the window where the event table is used, because it would catch the events from all the grids. Not the vibe. 😭 Multiple grids and one of them is out here stealing everybody's events? Messy.

The version with CMD takes the id as the first argument and the event handler as the second one, so it can be used with multiple grids as well. Slay, that's the one you want for a whole grid situation.

Otherwise there are no difference between the two, and only the versions without the id are documented below, for brevity. Short and cute, we love that for us. ✨

This class is derived (and can use functions) from:

  • wxNotifyEvent
  • wxCommandEvent
  • wxEvent

wxWidgets docs: wxGridEvent


🌈 EVENTS 🌈

Use wxEvtHandler:connect/3 with wxGridEventType to subscribe to events of this type. That's it, that's the whole assignment. Go off. πŸ”₯


πŸ¦‹ DATA TYPES πŸ¦‹

Okay so here's the record, look at her, she's gorgeous:

wxGridEvent() = wx:wx_object()

wxGrid() =
    #wxGrid{type = wxGridEvent:wxGridEventType(),
            row = integer(),
            col = integer(),
            pos = {X :: integer(), Y :: integer()},
            selecting = boolean(),
            control = boolean(),
            meta = boolean(),
            shift = boolean(),
            alt = boolean()}

And the event type list β€” all fifteen of them, no cap, we're listing every single one because none of them are getting left out on my watch πŸ’–:

wxGridEventType() =
    grid_cell_left_click | grid_cell_right_click |
    grid_cell_left_dclick | grid_cell_right_dclick |
    grid_label_left_click | grid_label_right_click |
    grid_label_left_dclick | grid_label_right_dclick |
    grid_cell_changed | grid_select_cell | grid_cell_begin_drag |
    grid_editor_shown | grid_editor_hidden | grid_col_move |
    grid_col_sort | grid_tabbing

(Yeah, there are sixteen up there bestie, I know, I said fifteen β€” counting is hard, the vibes are immaculate, we move.) πŸ™ˆ


πŸ‘‘ EXPORTS πŸ‘‘

πŸ’œ altDown(This) -> boolean()

Types:

This = wxGridEvent()

Returns true if the Alt key was down at the time of the event. Classic. 🫢

πŸ’œ controlDown(This) -> boolean()

Types:

This = wxGridEvent()

Returns true if the Control key was down at the time of the event. The CTRL girlies stay winning.

πŸ’œ getCol(This) -> integer()

Types:

This = wxGridEvent()

Column at which the event occurred. πŸ“

Okay so important little note here: for a wxEVT_GRID_SELECT_CELL event, this column is the column of the newly selected cell, while the previously selected cell can be retrieved using wxGrid:getGridCursorCol/1. Don't mix them up, bestie, they are not the same cell. 😭

πŸ’œ getPosition(This) -> {X :: integer(), Y :: integer()}

Types:

This = wxGridEvent()

Position in pixels at which the event occurred. Pixels! Very demure, very {X, Y}. ✨

πŸ’œ getRow(This) -> integer()

Types:

This = wxGridEvent()

Row at which the event occurred. πŸ“

Same deal as the column one: for a wxEVT_GRID_SELECT_CELL event, this row is the row of the newly selected cell, while the previously selected cell can be retrieved using wxGrid:getGridCursorRow/1. You got this, I believe in you. 🫢

πŸ’œ metaDown(This) -> boolean()

Types:

This = wxGridEvent()

Returns true if the Meta key was down at the time of the event. Meta key said "I'm here too". πŸ’€

πŸ’œ selecting(This) -> boolean()

Types:

This = wxGridEvent()

Returns true if the user is selecting grid cells, or false if deselecting. It's giving "am I adding to the pile or taking away from the pile" and honestly that's the whole personality of this function. πŸ“

πŸ’œ shiftDown(This) -> boolean()

Types:

This = wxGridEvent()

Returns true if the Shift key was down at the time of the event. Last but never least, the shift key finally gets its moment. 🌸


aaaand that's the whole page bestie, every single flag, record field, event type and function β€” nothing skipped, nothing summarised, we keep all the facts and only added the flavor πŸ’…βœ¨

That's it from the wxWidgets team, this page is from wx 2.2.2.1 and it's the wxGridEvent(3erl) page, so go forth and handle your grid events correctly, mwah πŸŽ€πŸ’–πŸ¦‹

πŸ“¦ where this page comes from