Desktop Drag&Drop files
Alex Shaw
A.Shaw at mailbox.gu.edu.au
Wed Nov 28 21:42:03 EST 2001
> > -----Original Message-----
> > From: Ben Rubinstein [mailto:benr_mc at cogapp.com]
> > Sent: mercredi 28 novembre 2001 13:45
> > To: metacard at lists.runrev.com
> > Subject: Re: [Metacard] Desktop Drag&Drop files
> >
> >
> > 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.
Thanks Ben
Haven't tried it yet.. :)
For windows.. it is easy .. compile your exe
Dropped files are accessed via the global variables $0 - app name/path; $1
- dropped file 1; etc
(see Help - Concepts & Techniques - The Outside World)
So to access the full path to the first file dropped onto the app:
put $1 into it
On windows it didn't matter what sort of file was dropped.. it accepted
everything .. files & folders. It then becomes a simple task of processing
each variable $1 -> $n (n - the last file). I don't have any folders with
thousands of files so I really don't know the limit of files it will
accept. Any1 any1?
thanks
alex
More information about the metacard
mailing list