[Metacard] Desktop Drag&Drop files

Ben Rubinstein benr_mc at cogapp.com
Wed Nov 28 07:51:16 EST 2001


on 27/11/01 6:09 AM, Alex Shaw at A.Shaw at mailbox.gu.edu.au wrote:

> -Simple executable app (or its alias/shortcut) which sits on the desktop.
> -User can drag & drop random files onto the app.
> -App processes files.
> 
> I can easily access the list thru the environment variable names $0 $1 $2
> etc on the pc but the same app on the mac returns empty variables & will
> only allow me to drop metacard files onto it.
> 
> Someone mentioned appleevents.. but how?

Alex,

I'll swap you Mac for Windows.

To do this on the Mac, your stack needs to handle the "appleEvent" message.

Put the following handler in your stack script:

    on appleEvent eClass, eID, eSender
       if eClass = "odoc" then
          request appleEvent data
          if the result = empty then
             answer "OpenDoc AppleEvent!" & return \
                & "id =" && eID \
                & "sender =" && eSender \
                & "data =" && it
          else
             pass appleEvent
          end if
       else
          pass appleEvent
       end if
    end appleEvent

Build a standalone, and try it.  You should see that when you drag and drop
a file, this handler fires, and the data for the apple event is the path of
the file(s).

The issue about which files you can drag-and-drop onto your app is
determined by the resources in the app.  When the standalone is built, it is
given the same resources as MetaCard itself - so it accepts stacks.   You
need to change these resources to identify the kind of files your app should
accept.  The resources in question are the file reference ('FREF'), icon
list ('ICN#') and bundle ('BNDL') resources.  You should be able to get
information about these on the apple site (developer.apple.com) (I'm on the
road at the moment, with email access only - can't give you exact
referencess.)  You'll need a resource editor - ResEdit or Resorceror.  Note
that you can only filter by Mac type codes, not by file extensions.

Now: can you tell me how I do this on Windows?!?  I can't even find out how
to access the environment variables.

Hope this helps & thanks in advance,
 
  Ben Rubinstein               |  Email: benr_mc at cogapp.com
  Cognitive Applications Ltd   |  Phone: +44 (0)1273-821600
  http://www.cogapp.com        |  Fax  : +44 (0)1273-728866





More information about the metacard mailing list