wxCloseEvent(3)

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

πŸ’– wxCloseEvent πŸ’–

ok so this is the Erlang Module Definition for wxCloseEvent(3) β€” yes bestie, page 3 of the manual, we're being ✨official✨ today.


🌸 NAME 🌸

wxCloseEvent β€” this event class is literally the one holding all the tea about window and session close events. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

The handler function for EVT_CLOSE gets called when the user tried to close a a frame or dialog box using the window manager (X) or the system menu (Windows). (yes, "a a" β€” the original said it, i'm not gonna gaslight u πŸ’€). It can also be invoked by the application itself programmatically, for example by calling the wxWindow:close/2 function.

You should check whether the application is forcing the deletion of the window using canVeto/1. If this is false, you must destroy the window using wxWindow:'Destroy'/1. no negotiating, no vibes, it's going down.

If the return value is true, it is up to you whether you respond by destroying the window. ur choice, ur main character moment. πŸ‘‘

If you don't destroy the window, you should call veto/2 to let the calling code know that you did not destroy the window. This allows the wxWindow:close/2 function to return true or false depending on whether the close instruction was honoured or not. like, communication is key bestie 🫢

Example of a wxCloseEvent handler:

k so the original page teases an example right here and then... gives u nothing. iconic of it honestly. πŸ™ˆ no code was provided, so i'm not inventing one β€” that would be lying and lying is not the vibe.

The EVT_END_SESSION event is slightly different as it is sent by the system when the user session is ending (e.g. because of log out or shutdown) and so all windows are being forcefully closed. At least under MSW, after the handler for this event is executed the program is simply killed by the system. πŸ’€ Because of this, the default handler for this event provided by wxWidgets calls all the usual cleanup code (including wxApp::OnExit() (not implemented in wx)) so that it could still be executed and exit()s the process itself, without waiting for being killed. If this behaviour is for some reason undesirable, make sure that you define a handler for this event in your wxApp-derived class and do not call event.Skip() in it (but be aware that the system will still kill your application). 😭

See:

  • wxWindow:close/2
  • Overview windowdeletion

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

  • wxEvent

wxWidgets docs: wxCloseEvent


✨ Events ✨

Use wxEvtHandler:connect/3 with wxCloseEventType to subscribe to events of this type. subscribe bestie, don't be shy πŸŽ€


🌈 DATA TYPES 🌈

wxClose() :: #wxClose{}.

wxCloseEvent() :: wx:wx_object().

wxCloseEventType() ::
          close_window | end_session | query_end_session.

πŸ’… FUNCTIONS πŸ’…

πŸ“ canVeto(This) -> boolean() when This :: wxCloseEvent().

Returns true if you can veto a system shutdown or a window close event.

Vetoing a window close event is not possible if the calling code wishes to force the application to exit, and so this function must be called to check this. like, u gotta ask first, that's just manners. ✨

🧚 getLoggingOff(This) -> boolean() when This :: wxCloseEvent().

Returns true if the user is just logging off or false if the system is shutting down.

This method can only be called for end session and query end session events, it doesn't make sense for close window event. so don't try it, it's giving delulu. 🫠

πŸŽ€ setCanVeto(This, CanVeto) -> ok when This :: wxCloseEvent(), CanVeto :: boolean().

Sets the 'can veto' flag. 🚩 (the good kind of flag)

🌸 setLoggingOff(This, LoggingOff) -> ok when This :: wxCloseEvent(), LoggingOff :: boolean().

Sets the 'logging off' flag.

πŸ‘‘ veto(This, [Option]) -> ok when This :: wxCloseEvent(), Option :: {veto, boolean()}.

Call this from your event handler to veto a system shutdown or to signal to the calling application that a window close did not happen.

You can only veto a shutdown if canVeto/1 returns true. no cap, that's the rule. πŸ”₯


fr fr, remember: canVeto/1 first, then decide. the whole thing falls apart if u skip the vibe check. πŸ’œ

and that's the whole page bestie, we ate and left no crumbs πŸ’– this lil slice of the docs came to u from Ericsson AB, tagged wx 2.6, and the page footer is stamped wxCloseEvent(3) β€” periodt. πŸ¦‹

πŸ“¦ where this page comes from