ACF-Plugin – New Feature: Drag and Drop Files

To make the user interface more intuitive when selecting files, drag-and-drop support enhances the overall experience. This is a new capability in ACF-Plugin v1.7.7.4 that is both flexible and easy to implement.

New Plugin Functions

The drag-and-drop feature is controlled by two new functions, which can be called directly from a Set Variable script step:

  • ACF_DefineDragAndDrop ( $$Coords ; "ReceiveDroppedFilesScript" ; $$DandDconfigJSON )
  • ACF_RemoveDragAndDrop ( 1 )

Required Scripts

To use drag-and-drop, you typically need three small scripts:

  1. Define the drag-and-drop area
    • You can get the coordinates from any field on your layout, or specify them manually.
    • Example:FieldBounds ( “” ; “DandDFiles” ; “DropArea” )This provides the required parameters for $$Coords.
    • The next parameter is the callback script name. This script receives a list of dropped file paths (in POSIX format).
    • You can convert the paths to FileMaker format with:ConvertToFileMakerPath ( $file ; PosixPath )
  2. The callback script
    • Handles the list of dropped files passed as script parameters.
  3. Remove the drag-and-drop handler
    • Call this when the handler is no longer needed, e.g. when exiting a layout or switching tabs.

Styling the Drop Area

The drop area can be styled with a JSON configuration object. You can control colors, tints, drag effects, directory handling, and accepted file types.

Example configuration:

{
   "allowDirectories": false,
   "border": true,
   "debug": false,
   "dragOpacity": 0.25,
   "extensions": [
       "pdf","png","jpg","xlsx","docx",
       "jpeg","zip","pptx","doc","rtf",
       "md","html","eml"
  ],
   "highlight": true,
   "highlightColor": "navy",
   "opacity": 0.12
}

Demo Application

We provide a demo app to showcase the drag-and-drop functionality. It is a small solution intended only for demonstration. You can download it along with the latest ACF-Plugin.

NamePlatformDescriptionDownloadDocsMore
DemoDandDMac (Intel+Arm)

FileMaker Drag- and drop demo application

Download-
DemoDandDWindows

FileMaker Drag- and drop demo application

Download-

The demo contains three small scripts:

Extended Privilege (FileMaker 19+)

For solutions created in FileMaker Pro 19 or later, you may need to enable an additional privilege to allow the plug-in to launch the “receive drop” script.

If the callback script is not triggered when files are dropped, check this setting:

  1. Open the solution in FileMaker Pro.
  2. Go to Manage → Security.
  3. Edit the relevant user’s Privilege Set (pencil icon).
  4. Under Extended Privileges, enable “Validate cross-file plug-in access (fmplugin)”.

Like this:

Once this is set, drag-and-drop will work as expected. 🎉

You may also like...