table of contents
wxCloseEvent(3erl) | Erlang Module Definition | wxCloseEvent(3erl) |
NAME¶
wxCloseEvent - Functions for wxCloseEvent class
DESCRIPTION¶
This event class contains information about window and session close events.
The handler function for EVT_CLOSE is called when the user has tried to close a 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.
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.
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.
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).
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.
DATA TYPES¶
wxCloseEvent() = wx:wx_object()
wxClose() = #wxClose{type = wxCloseEvent:wxCloseEventType()}
wxCloseEventType() =
close_window | end_session | query_end_session
EXPORTS¶
canVeto(This) -> boolean()
Types:
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.
getLoggingOff(This) -> boolean()
Types:
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.
setCanVeto(This, CanVeto) -> ok
Types:
CanVeto = boolean()
Sets the 'can veto' flag.
setLoggingOff(This, LoggingOff) -> ok
Types:
LoggingOff = boolean()
Sets the 'logging off' flag.
veto(This) -> ok
Types:
veto(This, Options :: [Option]) -> ok
Types:
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.
wx 2.2.1 | wxWidgets team. |