Sandboxing a Mac application - Save as dialog

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Sandboxing a Mac application - Save as dialog

Post by Mag » Sat Jan 07, 2017 8:12 pm

When you sandbox an app for Mac, your app have to use the standard OS dialog box to save a file on the disk. In LiveCode you use:

Code: Select all

ask file "Please name the file:"
In this way the OS let you create the file in the location user chosen with the name chosen by the user, e.g
/HD/Data Stacks/filedata.rev
What appens if the user omits the .rev extension in the save as dialog and you need the file to have it? E.g:
/HD/Data Stacks/filedata
You could try add it via code, then save the file as:
/HD/Data Stacks/filedata.rev

Unfortunately the security features of macOS, won’t let you safe the file because user has chose “filedata” and not “filedata.rev”.

So, my question is: how can we force user to put the extension in the save as dialog?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4993
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Sandboxing a Mac application - Save as dialog

Post by dunbarx » Sun Jan 08, 2017 1:44 am

Couldn't you check the user input, and add the extension if it is not present?

Craig

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Sandboxing a Mac application - Save as dialog

Post by Mag » Sun Jan 08, 2017 2:25 am

Hi Craig, unfortunately once the app is sandboxed, you can only use the file that user specifies. :(

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Sandboxing a Mac application - Save as dialog

Post by Mag » Sun Jan 08, 2017 11:08 am

Since on the Mac extensions are mainly for compatibility, maybe I should leave free the user not to use them and rely only on mime type and creator of the file?

Code: Select all

set the stackFileType to "myapMYDC"

Klaus
Posts: 9619
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sandboxing a Mac application - Save as dialog

Post by Klaus » Sun Jan 08, 2017 12:07 pm

Déjà vue? :shock:

To be honest, if only your app will access these user saved files,
you do not need any extension at all on any platform!

The engine can open any valid stack file, no matter what they are named,
even something like: I_am_a_real_Livecode_stack_in_disguise.txt :D


Best

Klaus

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Sandboxing a Mac application - Save as dialog

Post by Mag » Sun Jan 08, 2017 1:44 pm

Hi Klaus, thanks for your valuable contribution.

My main goal now is that when you double-click on the document, the app is opened (and also the document's icon has to be displayed properly). I have to figure out if the type and creator are sufficient or if I have to force the user to put the extension in the filename when she/he saves the document.

Many Mac users do not know how to use the filename extensions because by default the Mac does not show them.
chfl.png
I seem to have realized that LiveCode does not respect the "show all filenames extensions" choice made in the Finder preferences in the "ask file" dialog box and shows the extension in the name field of the box also if the preferences of the Finder is set to false. So the extension is exposed in the ask file dialog with the risk that the user deletes it, this is why I needed to know if it's mandatary to have it or not in the filename.

Yes, I know, it is a complicated topic full of details, sorry about that ... :oops:

PS
Maybe do you refer to this topic: http://forums.livecode.com/viewtopic.php?f=19&t=28238 ? If so, get ready! There are still many things we need to talk, the sandbox is a hot topic and increasingly topical! hehehe :lol:

Klaus
Posts: 9619
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sandboxing a Mac application - Save as dialog

Post by Klaus » Sun Jan 08, 2017 4:41 pm

Hi Mag,

ah, yes you need the extension for a possible doubleclick!

Since this is a bit complicated on the Mac I never let my users do this,
my apps always managed all user-saved files for them! :D

And with "Déjà vue" I meant this one:
http://forums.livecode.com/viewtopic.ph ... 17#p149517


Best

Klaus

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Sandboxing a Mac application - Save as dialog

Post by Mag » Sun Jan 08, 2017 5:14 pm

Klaus wrote:Since this is a bit complicated on the Mac I never let my users do this,
my apps always managed all user-saved files for them! :D
After working for a few weeks of that, I think yours is the best approach (It also avoids the risk of open stacks with the same name of stacks already open or with names made of integers).

So, do you propose to the user a list of saved documents from which the user chooses which open?

Klaus wrote:And with "Déjà vue" I meant this one:
http://forums.livecode.com/viewtopic.ph ... 17#p149517
Oh, yes, now I see ... or rather, I re-see... :lol:

Klaus
Posts: 9619
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Sandboxing a Mac application - Save as dialog

Post by Klaus » Sun Jan 08, 2017 5:29 pm

Mag wrote:
Klaus wrote:So, do you propose to the user a list of saved documents from which the user chooses which open?
Exactly! :D

Post Reply

Return to “Mac OS”