Does anyone know how to effect the reopen windows after restart function in a Xojo app?
Is there an apple function via a declare somewhere?
You should be able to handle the open document apple events
The os records the open windows & sends you an event to reopen them
you can try NSApplicationDelegateMBS class in MBS Plugins
http://www.monkeybreadsoftware.net/class-nsapplicationdelegatembs.shtml
Maybe the restoreWindowWithIdentifier event there?
Norman
I have the open document event configured - it works fine with double clicking documents to open them in the app - but nothing comes up on restarting windows, or on reopening the app after closure.
I would have expected the required event to include additional information about the window - such as positioning, sizing, fullscreen, spaces etc. I’ll take a look at Christians classes.
Christian - I don’t suppose you have any worked examples of the nsApplicationDelegateMBS class - it looks rather complex (for me )
[quote=232938:@James Pitchford]Does anyone know how to effect the reopen windows after restart function in a Xojo app?
Is there an apple function via a declare somewhere?[/quote]
Do you mean within your app or system wide ?
Do you want your app to start automatically when the system is restarted ?
Within my app Michel.
I’ve just re-read Norman’s reply above and I see there is an app.handleAppleEvent which he must have been referring to - and your associated thread from last year.
a few examples use the delegate class.
e.g. see Save and restore State example project.
[quote=232969:@James Pitchford]Within my app Michel.
I’ve just re-read Norman’s reply above and I see there is an app.handleAppleEvent which he must have been referring to - and your associated thread from last year.[/quote]
Upon close I would use the Window function to place all open windows titles in a file, together with their size and position. Then save the file in AppData.
Upon start, I look for the file, and use a big Select case to show the windows depending on the titles.
The alternative is to instanciate as invisible all windows in the app, reveal only those which title correspond, and close those not mentioned.
Thanks Michel - that looks like the simplest solution for now.
To support Resume in a Xojo built application is a little bit complicated.
I have a working (but not 100% technically correct) solution as part of the Sandbox Kit, which is Sandbox safe and accepted on the Mac App Store.
Christian and I worked together on trying to produce a 100% technically correct way of doing, but it becomes such an overkill. So much code to required and hacking of delegates.
Thanks Sam - I’ll keep it simple by coding specific to my app - open documents, windows & positions, selected items, navigation positions - I suppose I could add FullScreen - but don’t see how I can do the OSX stuff like Spaces so I’ll leave that out.
James,
Not a problem, I’ve been where you are and have battled with these, hence why I created the Sandbox Kit in the first place.
Sandboxing was a long fight.