Avoid automatic opening of last opened files

Maybe did you notice that, since Mountain Lion, there is a difference between close all files and then the app, and directly quit the app.

Indeed, in the second case, when you restart your app, it automatically opens last files.

I want my application to avoid this behaviour, does anyone know how to do that, apart from specify this in the finder’s preferences???

I do not think you can prevent it, it depends on what the user has set in System Settings.

Are you building a Carbon based application? If so, then there’s not much you can do about it.

If you’re building Cocoa, then you have to do a ton of work to get this functionality!

I don’t want to set that in the global preferences of the system.

If you try with OpenOffice, for example, this app doesn’t reopen previous files, so I can imagine there is a possibility to specify that in my app?

Is there a new parameter in the «open» function of the app in XOJO?

How does OSX even do this? Does it record all modeless windows created (I guess the term is “registered”) that have not been destroyed when app shutdown is being requested?

I ask this because I do this on purpose for one of my apps. On app shutdown, I record all windows open and what their contents are, save a persistent file, and then that file gets opened the next time the app is opened and spawns all the windows again. Should I just skip this area of code if the app is running in 10.8 and up?

[quote=114538:@Garth Hjelte]How does OSX even do this? Does it record all modeless windows created (I guess the term is “registered”) that have not been destroyed when app shutdown is being requested?

I ask this because I do this on purpose for one of my apps. On app shutdown, I record all windows open and what their contents are, save a persistent file, and then that file gets opened the next time the app is opened and spawns all the windows again. Should I just skip this area of code if the app is running in 10.8 and up?[/quote]
Yes

OS X basically has a means to record an alias for every opened document then restores those when you open the app

Opened Document and Opened Window are two different things, though.

In my situation, sure, each opened REAL/Xojo Window corresponds to a file/document/folderitem/whatever, but given your answer I’m not sure if OSX knows what I’m doing.

Does 10.8+ do this only when your app is THE APP according to OSX that opens that file’s filetype? In other words, for example, if my “Edit Big Chunk” app opens .bigchunk files, and through REAL/Xojo App.OpenDocument function it opens it (and it’s listed in FileTypes and App.AcceptFileTypes), OSX remembers it so upon app startup OSX essentially throws a bunch of FolderItems at App.OpenDocument.

Is that correct?

Quite honestly you cannot tell the difference between the OS reopening these & a user dragging and dropping a bunch of files on to your app

So if you’re saving & reopening things then you’ll probably do it twice - once for your saved data & once more for the OS reopening them