Feedback
Add cancellable Window.CancelClosing event
- Status
- Fixed
- Fixed in
- v26.5.5
- Source discussion
- https://forum.objo.dev/d/79-missing-things-in-class-window
- Last updated
- 2026-05-21
Public summary
Add a cancellable desktop window close event so an ObjoBasic app can reject a close request before the native window actually closes. Current Objo has a Window.Close event, but it is a notification-style event queued through the VM callback path and cannot cancel Avalonia's Closing event. Desktop apps need this for unsaved documents, validation failures, modal workflows, and confirmation prompts.
Suggested API:
Event CancelClosing(appQuitting As Boolean) As Boolean
Return True # cancel close
End Event
CancelClosing should fire before the non-cancellable close/cleanup event. Returning True prevents the window from closing. The appQuitting parameter is True when the close request is part of application shutdown and False when only this window is being closed.
Example workflow:
Event CancelClosing(appQuitting As Boolean) As Boolean
If HasUnsavedChanges Then
Var result As Integer = MessageBox("Discard unsaved changes?")
Return result <> MessageBoxResult.OK
End If
Return False
End Event