wxCommandEvent(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

✨ NAME ✨

okay so bestie, gather round: wxCommandEvent(3) β€” this is the Erlang Module Definition for wxCommandEvent, and it's literally the event class that holds all the info about command events, the ones that come from a whole bunch of simple controls. 🫢


🌸 DESCRIPTION 🌸

first thing, and this is the important one: wxCommandEvents, and every event class derived from wxCommandEvent, propagate upward by default β€” from the source window (the window that emits the event) up to the first parent which processes the event. And this is unlike other wxEvent-derived classes, so don't be surprised, okay? Be sure to read overview_events_propagation. fr fr. πŸ“–βœ¨

Also, more complex controls β€” like wxTreeCtrl, hi queen β€” have their own separate command event classes. So this one is not covering those. πŸ’…

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

  • wxEvent

wxWidgets docs: wxCommandEvent

πŸŽ€ Events πŸŽ€

Use wxEvtHandler:connect/3 with wxCommandEventType to subscribe to events of this type. that's the whole vibe check, go off ✨


πŸ¦‹ DATA TYPES πŸ¦‹

wxCommand() :: #wxCommand{}.
wxCommandEvent() :: wx:wx_object().
wxCommandEventType() ::
          command_button_clicked | command_checkbox_clicked |
          command_choice_selected | command_listbox_selected |
          command_listbox_doubleclicked | command_text_updated |
          command_text_enter | text_maxlen | command_menu_selected |
          command_slider_updated | command_radiobox_selected |
          command_radiobutton_selected | command_scrollbar_updated |
          command_vlbox_selected | command_combobox_selected |
          combobox_dropdown | combobox_closeup | command_tool_rclicked |
          command_tool_enter | tool_dropdown |
          command_checklistbox_toggled | command_togglebutton_clicked |
          command_left_click | command_left_dclick |
          command_right_click | command_set_focus | command_kill_focus |
          command_enter | notification_message_click |
          notification_message_dismissed | notification_message_action.

look at all those atoms, she's iconic for that πŸ’œ


πŸ’… FUNCTIONS πŸ’…

getClientData

getClientData(This) -> term() when This :: wxCommandEvent().

Returns the client object pointer for a listbox or choice selection event β€” and heads up, not valid for a deselection. πŸ™ˆ

getExtraLong

getExtraLong(This) -> integer() when This :: wxCommandEvent().

Returns extra information that depends on the type of the event object. iykyk, it's giving "it depends".

If the event comes from a listbox selection, it's a boolean deciding whether the event was a selection (true) or a deselection (false). And a listbox deselection only happens for multiple-selection boxes β€” and in that case the index and string values are indeterminate and your application has to go examine the listbox itself. so like, don't trust those values, bestie. 😭

getInt

getInt(This) -> integer() when This :: wxCommandEvent().

Returns the integer identifier corresponding to a listbox, choice or radiobox selection (only if the event was a selection, not a deselection), or a boolean value representing the value of a checkbox.

For a menu item, this method returns -1 if the item is not checkable, or a boolean value (true or false) for checkable items, indicating the new state of the item. periodt. πŸ”₯

getSelection

getSelection(This) -> integer() when This :: wxCommandEvent().

Returns the item index for a listbox or choice selection event β€” again, not valid for a deselection. πŸ™ˆ

getString

getString(This) -> unicode:charlist()
                  when This :: wxCommandEvent().

Returns the item string for a listbox or choice selection event. πŸ“

If one or several items have been deselected, it returns the index of the first deselected item. And if some items got selected and others got deselected at the same time? It'll return the index of the first selected item. multitasking queen πŸ‘‘

isChecked

isChecked(This) -> boolean() when This :: wxCommandEvent().

This one works with checkbox and menu events: for checkboxes, it returns true for a selection event and false for a deselection one. βœ…

For menu events, it indicates whether the menu item just became checked or unchecked β€” so it only makes sense for checkable menu items, ngl.

Notice: this method cannot be used with wxCheckListBox currently. πŸ’€ that's just how it is.

isSelection

isSelection(This) -> boolean() when This :: wxCommandEvent().

For a listbox or similar event, returns true if it's a selection, false if it's a deselection. 🌈

And if some items were selected while others were deselected at the same time, it returns true. she picks a side πŸ’…

setInt

setInt(This, IntCommand) -> ok
                when This :: wxCommandEvent(), IntCommand :: integer().

Sets the m_commandInt member. simple as that ✨

setString

setString(This, String) -> ok
                   when
                       This :: wxCommandEvent(),
                       String :: unicode:chardata().

Sets the m_commandString member. cute, done, slay πŸŽ€


and that's the whole page, bestie!! this one came to you courtesy of Ericsson AB and wx 2.6 β€” go forth and connect your event handlers, you've got this πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from