wxCloseEvent(3erl)

πŸŽ€ NAME πŸŽ€

wxCloseEvent β€” functions for the wxCloseEvent class, bestie. This whole page is the Erlang Module Definition for it, and it's literally the close-event group chat: window closes, session closes, veto flags, the whole dramatic arc. πŸ’–βœ¨

🌸 DESCRIPTION 🌸

okay so this event class contains information about window and session close events. That's the vibe, no cap. 🫢

The handler function for EVT_CLOSE is called when the user has tried to close a frame or dialog box using the window manager (X) or system menu (Windows). It can also be invoked by the application itself programmatically, for example by calling the wxWindow:close/2 function. Very main character energy. πŸ’…

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. Not optional, bestie β€” that's a hard requirement. 🚨

If the return value is true, it is up to you whether you respond by destroying the window.

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. Honoured is doing a lot of work in that sentence, iykyk. ✨

Example of a wxCloseEvent handler:

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). Like, the system is still gonna do its thing, so don't shoot the messenger. πŸ’€

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. That's the subscribe-and-slay pipeline. 🌈

πŸ¦‹ DATA TYPES πŸ¦‹

wxCloseEvent() = wx:wx_object()

wxClose() = #wxClose{type = wxCloseEvent:wxCloseEventType()}

wxCloseEventType() =
    close_window | end_session | query_end_session

πŸ’… EXPORTS πŸ’…

canVeto(This) -> boolean()

Types:

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, it's the vibe check for veto power. πŸ‘‘

getLoggingOff(This) -> boolean()

Types:

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 there, bestie. πŸ™ˆ

setCanVeto(This, CanVeto) -> ok

Types:

This = wxCloseEvent()
CanVeto = boolean()

Sets the 'can veto' flag. Cute little flag, very important. πŸŽ€

setLoggingOff(This, LoggingOff) -> ok

Types:

This = wxCloseEvent()
LoggingOff = boolean()

Sets the 'logging off' flag.

veto(This) -> ok

Types:

This = wxCloseEvent()

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

Types:

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. Periodt. πŸ’…


source/version/date-ish sign-off: wxWidgets team Β· wx 2.2.2.1 Β· wxCloseEvent(3erl) β€” that's the whole page, bestie, and there's no separate date on this footer, so we're not inventing one. now go slay those close events with main character energy πŸ’–πŸŽ€βœ¨

πŸ“¦ where this page comes from