Display dialog on application quit?
I’d like to display "are you sure you want to quit? (yes) (no)" message when the user tries to close a standalone Max application. Is this possible? I imagine this can be done via a special (quit) button on the interface that triggers the dialog, but is this possible when using the OS window close control? Cheers!
probably (dirty) message to [thispatcher] ; though not sure in standalone ( (dirty) will ask for saving changes, so standalone i don’t know what it will ask)
you might want to look at [closebang] also
"Are you sure you want to quit?" is non-standard UI, so probably not a good idea unless you’ve got very special circumstances. You probably feel your circumstances are special, but hard to judge.
Anyway: coupla things you can do.
1) Set up a custom menu and menu handler and do what you want in your quit handler. Check tutorials for custom menus in collectives/standalones. Actually, I think this may be the only practicable approach. This allows you to completely re-structure the default menu bar, which may have lots of advantages.
Otherwise, look at [closebang]. The problem here is that I don’t think that object can cancel the quit process. But it might be capable of handling a "Save unsaved changes?" type of dialog.
By all means try a ‘dirty’ message to your patcher, but, I have the same doubts about this as Vichug. Let us know if it works for you.
Peter and Vichuk, thank you both for your replies and suggestions! As you suspected, marking [thispatcher] dirty did not cancel the quit process in a standalone. Nor did a [closebang] into [dialog], or into a custom subpatch dialog window — both exited immediately without displaying any dialog. However a [closebang] into [savedialog] does interrupt quit process.
I am actually trying to display a "save unsaved changes?" dialog. The "are you sure you want to exit?" was a bad example of what I’m actually trying to do! So it looks like a solution using [closebang] into [savedialog] is possible. However I’d like to supply a folder path into [savedialog] to open the location where user should write their data — the location where other application data will be stored, so that I can open this location next time the user runs the app. It looks like [savedialog] doesn’t accept a folder path though. Are you aware of any ways to skin this cat? Thanks again!
On further digging, it looks like I can specify the folder I want to open in [savedialog] by supplying the folder path into [relativepath]->[prepend set]->[filepath default], so that should work for what I’m trying to do. Thanks again!
DOOOOH! I guess that wasn’t it… In my test patch I was actually using [opendialog] to select the folder path, and it looks like THAT’S what was causing the folder path to also open in [savedialog]… not supplying the folder path to [filepath default] like I mistakenly assumed… Jus’ shootin from the hip over here!
Anyway, I’m open to suggestions if you are aware of a way to supply a folder path into [savedialog]. In the meantime I might have to start looking at the custom menu handlers Peter suggested. Cheers!