Drag-and-Drop with Desktop Files

kee nethery kee.nethery at elloco.com
Thu Mar 14 16:40:45 EDT 2019


I had drag and drop in my macOS app but … when going with the AppStore, and sandboxing, there was no way for drag and drop to trigger the sandbox permission that would allow the app to read that file. I knew which file, but since it did not go through the dialog box, the permission wasn’t set.

So I took drag and drop out of my app and it passed store app review.

Kee

> On Mar 13, 2019, at 4:44 PM, hh via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> ** Get selected files of the file manager (without user interaction like dragDrop) **
> 
> (I write the following such that also beginners can read it.)
> 
> +++++++++++++++++++++++
> [a] Solution for MacOS (tested to work on MacOS 10.14):
> 
> (a1) Put the following in a field "myScript".
> 
> # Full path of selected items in Finder.
> tell application "Finder"
>   set finderSelList to selection as alias list
> end tell
> 
> if finderSelList ≠ {} then
>   repeat with i in finderSelList
>      set contents of i to POSIX path of (contents of i)
>   end repeat
>   set AppleScript's text item delimiters to linefeed
>   finderSelList as text
> end if
> 
> 
> (a2) Script a button and create a field "OUT".
> on mouseUp
>   do fld "myScript" as applescript
>   put char 2 to -2 of the result into r
>   put r into fld "OUT"
> end mouseUp
> 
> You'll get from the top-layered finder window lines with the full file names.
> 
> (a3) Credits.
> https://forum.keyboardmaestro.com/t/getting-the-path-of-currently-selected-file-in-finder/1507
> 
> +++++++++++++++++++++++++
> [b] Solution for Windows (tested to work on Win 7+10):
> 
> (b1) Save the following to a file "wscript1.js" in your stacks folder.
> 
> var shellWindows = new ActiveXObject("Shell.Application").Windows();
> for (var i = 0; i < shellWindows.Count; i++) {
> var w = shellWindows.Item(i);
> WScript.StdOut.WriteLine(w.LocationName);
> var sel = w.Document.SelectedItems();
> for (var j = 0; j < sel.Count; j++) {
> var item = sel.Item(j);
> WScript.StdOut.WriteLine(item.Name);
> WScript.StdOut.WriteLine(item.Path);
> }
> }
> 
> (b2) Script a button and create a field "OUT".
> 
> on mouseUp
>  put the effective filename of this stack into p
>  set itemdel to slash
>  put "wscript1.js" into last item of p
>  put shell("wscript "&p) into fld "OUT"
> end mouseUp
> 
> You'll get for each explorer window its name and, for each selected file in that,
> the short file name followed in the next line by the long file name.
> 
> (b3) Credits.
> https://devblogs.microsoft.com/oldnewthing/?p=4593
> 
> +++++++++++++++++++++++++
> [c] Solution for linux:
> 
> Linux nerds of the use-list, please complete here (at least for ubuntu 1604) ...
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list