wxFocusEvent(3)

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

πŸ’– wxFocusEvent πŸ’–

okay bestie, welcome to the Erlang Module Definition for wxFocusEvent β€” yes that's the module name, it's in the wx family, and it's giving main character energy in the focus department πŸ’…


✨ NAME ✨

wxFocusEvent β€” bestie, a focus event gets sent when a window's focus changes. that's it, that's the vibe πŸ¦‹


🌸 DESCRIPTION 🌸

so here's the tea: the window that's losing focus receives a "kill focus" event, and the window that's gaining it gets a "set focus" one. it's giving breakup and glow-up at the same time πŸ˜­πŸ’”βœ¨

be aware (lowkey important): the set focus event happens both when the user gives focus to the window β€” whether that's with the mouse or the keyboard β€” and when it's done from the program itself using wxWindow:setFocus/1. so it's not just a user thing, your own code can trigger it too, no cap πŸ‘‘

the focus event handlers should almost invariably call wxEvent:skip/2 on their event argument so the default handling can take place. fr fr, if you don't do this you may get incorrect behaviour of the native controls πŸ’€ not a vibe. also β€” and this is the big one β€” a wxEVT_KILL_FOCUS handler must not call wxWindow:setFocus/1, because again, that's not supported by all native controls πŸ™ˆ. if you genuinely need to do that, consider using the Delayed Action Mechanism (not implemented in wx), which is described over in the wxIdleEvent documentation. iykyk 🧚

See: Overview events

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

  • wxEvent

wxWidgets docs: wxFocusEvent

πŸ‘€ Events πŸ‘€

use wxEvtHandler:connect/3 with wxFocusEventType to subscribe to events of this type. go off, subscribe, be notified πŸŽ€


🌈 DATA TYPES 🌈

  • wxFocus() :: #wxFocus{}.
  • wxFocusEvent() :: wx:wx_object().
  • wxFocusEventType() :: set_focus | kill_focus.

periodt. two types of focus energy, pick your fighter ⭐


🫢 FUNCTIONS 🫢

  • getWindow(This) -> wxWindow:wxWindow() when This :: wxFocusEvent().

returns the window associated with this event β€” which is literally the window that had the focus before, for the wxEVT_SET_FOCUS event, and the window that's going to receive focus, for the wxEVT_KILL_FOCUS one. so it's a different window depending on which event you're in, bestie, don't get it twisted πŸ’…

⚠️ Warning: the window pointer may be NULL! 😱 check it before you dereference it, or it's giving segfault core.

that's the whole page, no skips, no summaries, every flag and every fact accounted for 🌟 stan a well-documented event class.

this was brought to you by Ericsson AB, wx 2.6, page wxFocusEvent(3) β€” mwah, go forth and skip your events properly πŸ’–πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from