Droplets .. how to

Anyone has a good idea how to implement droplets for your app?

Droplets are basically icons were the user can drop things on and ‘sent’ it to your app. It should sent the file path (of the dropped file) and some options/data to your app.

  • create a canvas
  • use it to draw your “icon”
  • assign AcceptFileDrop parameters to the canvas
  • add a DropObject event to the Canvas
  • see the Lang Ref

If by icons, you mean icons on the Desktop, then that should cause the program to be launched but with a command line argument with the object’s path and filename.

Look into System.CommandLine and during app startup, check if something was passed then act accordingly.

[quote=454844:@Douglas Handy]If by icons, you mean icons on the Desktop, then that should cause the program to be launched but with a command line argument with the object’s path and filename.

Look into System.CommandLine and during app startup, check if something was passed then act accordingly.[/quote]

And how to create an icon (on for example the desktop) that start your app with extra arguments?

[quote=454841:@Dave S]* create a canvas

  • use it to draw your “icon”
  • assign AcceptFileDrop parameters to the canvas
  • add a DropObject event to the Canvas
  • see the Lang Ref[/quote]

Although that is a solution (create an app that then launch another app). The droplet would be rather big (at least 3MB). Droplets are mostly very tiny (<50k).

by “for your app” I “assumed” the OP referred to an icon within the app it self…

otherwise what you propose is just a custom desktop icon and is outside the pervue of Xojo all together, and rather is specific to the OS involved (be it macOS, Win or Linux)

You are essentially talking auto creating a “shortcut” or an “alias” or whatever.

Quick web search suggests looking here and here

Web searches are your friend.

A shortcut or alias is not what I need (I guess).
A possible solution would be to create a terminal batch file that launch your app with options.

Create a text file with:
open a b c

Then do
chmod 755

This results in a batch file that will launch your app when double clicking on it. But the problem here is that dropping a file on the batch file will do nothing. Unless there is a way to let it accept files to drop on would be a very good solution for creating ‘droplet’ icons.

You mean this?
https://support.apple.com/kb/PH21240?viewlocale=en_AM&locale=en_AM

That type of feature i mean

[quote=454861:@Derk Jochems]You mean this?
https://support.apple.com/kb/PH21240?viewlocale=en_AM&locale=en_AM

That type of feature i mean[/quote]

Yes, that’s exactly what I mean. :slight_smile:
Now, how to make this work is another question. :slight_smile:

You can create an applescript droplet that accepts a file/files and then sends a command to your app. Your app handles the apple event.
MBS has Applescript functions… not sure if it can compile and save as an app, but I would bet it can.

As far as I know, you cannot create a AppleScript file with AppleScriptMBS.
It can only compile the ApleScript code and execute it. So that rules out AppleScript for making custom in-app Applescripts.

https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/ProcessDroppedFilesandFolders.html

So, the real sentence would have to be:

OK, OK, I am a specialist of this kind of writings, sorry :wink:

on macOS you can write the script (as plain text) then use the command line osacompile to compile the droplet into an executable
and since that is now just an executable app you can put it where ever (on the desktop for instance)
dunno if MBS exposes osacompile

Edit : in terminal

man osacompile

will give you all the options