Associating FileTypes to a Rev Standalone

Ben Rubinstein benr_mc at cogapp.com
Tue May 28 06:02:01 EDT 2002


on 28/5/02 2:26 AM, David Egbert at degbert at mac.com wrote:

> In SuperCard, to enable drag and drop in a standalone app, you must
> associate a Macintosh file type (4 digit code) of the document to the
> standalone.  This magically enables the app to highlight when you drag the
> file over the app's icon (Applescript is needed to do something to the file,
> once you drop it on the icon).
> 
> Is there a way to do this in Rev?  I'd like to create my own file type and
> open files by dragging and dropping the docs on the app's icon.  I've been
> poking around in ResEdit to find differences, but I'm not having much
> success.  Any help would be appreciated.


One day there will I'm sure be a topic in the Enclopedia/Development Guide
covering both these things.  My quick sketch follows - note that this (and
my knowledge) is MacOS 9 only - perhaps someone could fill in the story for
MacOS X?

Two things required here: to associate the standalone with file types; and
to handle the files being dropped onto the app's Finder icon.   Also you
probably know that you should register your file type (and creator
signature) with Apple, to make sure it is unique.  Free, quick, on the web
at:
    http://developer.apple.com/dev/cftype/

To associate the app with your file type, you need to add several resources
to the app: BNDL, FREF, and an 'owner resource' whose type is the same as
your app creator signature.  You'll probably also want to create icon
resources (the full set is ICN#, icl8, icl4, ics#, ics8, ics4 - but your
resource editor will probably sort this for you transparently).

Details of all this on Apple's web site - eg (I don't swear this is the best
reference)
    http://developer.apple.com/techpubs/mac/Toolbox/Toolbox-451.html

When you've got these resources created, you can put them in a separate file
and use the MacOS Options tab on the Distribution Builder to add them
automatically each time the standalone is built.

All this if it works right means that the Finder will allow the user to drop
files of this type onto your app (and also will give the files the correct
icon, and ensure your app is launched if they are double-clicked).

To respond to the drag and drop, you need to handle the 'odoc' Apple event.
See the rev documentation for appleEvent; this message will be sent when a
Finder wants you to open a file, with class "aevt", and id "odoc".  The data
for the apple event will be the path to the file(s) to open.

Hope this helps,

  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 use-livecode mailing list