wxEvent(3erl)

πŸ’… wxEvent β€” okay bestie, let's talk events

So this is wxEvent(3erl), straight out of the Erlang module definitions, and it's literally the base class for every event in wxWidgets. Let's get into it 🫢


✨ DESCRIPTION ✨

An event is, like, a structure holding info about an event that gets passed to a callback or a member function. That's the whole vibe.

wxEvent used to be a multipurpose event object (iconic of it, honestly), and now it's the abstract base class for all the other event classes β€” see below, bestie πŸ‘‡

For more info about events, go check out the overview_events overview. It's giving required reading.

See: wxCommandEvent, wxMouseEvent

wxWidgets docs: wxEvent


πŸŽ€ DATA TYPES πŸŽ€

  • wxEvent() = wx:wx_object()

πŸ”₯ EXPORTS πŸ”₯

getId(This) -> integer()

Types:

This = wxEvent()

Returns the identifier associated with this event β€” like a button command id. It's the event's little name tag πŸ’–

getSkipped(This) -> boolean()

Types:

This = wxEvent()

Returns true if the event handler should be skipped, false otherwise. Simple as that, no cap.

getTimestamp(This) -> integer()

Types:

This = wxEvent()

Gets the timestamp for the event.

Okay so the timestamp is the time in milliseconds since some fixed moment β€” and heads up, it's not necessarily the standard Unix Epoch, so only the differences between timestamps usually make sense, not their absolute values. Don't be out here comparing timestamps to your clock, bestie 😭

⚠️ Warning: wxWidgets returns a non-NULL timestamp only for mouse and key events (see wxMouseEvent and wxKeyEvent). So for everything else? Null. Nothing. Crickets. πŸ’€

isCommandEvent(This) -> boolean()

Types:

This = wxEvent()

Returns true if the event is or is derived from wxCommandEvent, else it returns false.

Note: exists only for optimization purposes. It's not doing anything deep, it's just fast. Respect tho.

resumePropagation(This, PropagationLevel) -> ok

Types:

This = wxEvent()
PropagationLevel = integer()

Sets the propagation level to the given value β€” for example, a value returned from an earlier call to stopPropagation/1. It's the "ok we're back on" button πŸ¦‹

shouldPropagate(This) -> boolean()

Types:

This = wxEvent()

Tests if this event should be propagated or not β€” aka, is the propagation level currently greater than 0? That's it, that's the whole check ✨

skip(This) -> ok

Types:

This = wxEvent()

(The one-arg version. Short, sweet, does the thing.)

skip(This, Options :: [Option]) -> ok

Types:

This = wxEvent()
Option = {skip, boolean()}

This method can be used inside an event handler to control whether further event handlers bound to this event will be called after the current one returns. Very main character of it.

Without skip/2 (or equivalently, if Skip(false) is used), the event will not be processed any more. If Skip(true) is called, the event processing system continues searching for a further handler function for this event β€” even though it's already been processed in the current handler. So it keeps the search going πŸ”₯

In general, it's recommended to skip all non-command events to allow the default handling to take place. Command events, though, are normally not skipped β€” because usually a single command like a button click or a menu item selection must only be processed by one handler. One handler, one job, periodt πŸ’…

stopPropagation(This) -> integer()

Types:

This = wxEvent()

Stops the event from propagating to its parent window. πŸ›‘

Returns the old propagation level value, which you may later pass to resumePropagation/2 to allow propagating the event again. So keep that return value, bestie β€” it's your way back in πŸ™ˆ


and that's the whole page, you ate that πŸ’–

Cute little sign-off: this gem comes to you from the wxWidgets team, version wx 2.2.2.1, and it's the wxEvent(3erl) page β€” go forth and handle your events responsibly πŸŽ€βœ¨

πŸ“¦ where this page comes from