[comp.sys.mac.programmer] What files are selected in Finder?

jnh@ecemwl.ncsu.edu (Joseph N. Hall) (09/28/89)

Hmm.  I'm curious as to whether there's a way to determine what files
are currently selected in the Finder.  What I had in mind was an FKEY that
would do something simple to whatever files were selected (say, set or
reset their bundle bits).  Is there a reasonable way to do this?  It would
be SO much more sensible and practical than putting up a standard file
dialog, etc. ...

v   v sssss|| joseph hall                      || 4116 Brewster Drive
 v v s   s || jnh@ecemwl.ncsu.edu (Internet)   || Raleigh, NC  27606
  v   sss  || SP Software/CAD Tool Developer, Mac Hacker and Keyboardist
-----------|| Disclaimer: NCSU may not share my views, but is welcome to.

ech@cbnewsk.ATT.COM (ned.horvath) (10/03/89)

From article <4062@ncsuvx.ncsu.edu>, by jnh@ecemwl.ncsu.edu (Joseph N. Hall):
> Hmm.  I'm curious as to whether there's a way to determine what files
> are currently selected in the Finder.  What I had in mind was an FKEY that
> would do something simple to whatever files were selected (say, set or
> reset their bundle bits).  Is there a reasonable way to do this?  It would
> be SO much more sensible and practical than putting up a standard file
> dialog, etc. ...

AH!  What a WONDERFUL AppleEvents message to send to the 7.0 Finder!  Let's
see if we can design it:
	1 Dear Finder, please advise me when the selection changes.  This
	  might be too expensive.
	2 Dear Finder, please advise me when the selection is dragged
	  to a new icon (or a particular icon) (or a new window)
	  (or a particular window).
	3 Same as 2, but give me "first refusal," i.e. let me try to 
	  handle the command.  This is already default behavior for
	  Open (and sort-of for print) for files with the same creator.
	4 Same as 3, but some other command (open, print, etc).
	5 Send the selection when I become active.  Or pop it in the
	  Clipboard whenever I become active and it's changed.
	6 Activate Finder, accept a selection, return it to me when the
	  user says "OK."  This could replace SFGetFile.
	7 Like 6, activate Finder, let user open/create folders, return
	  top open folder vRefNum.  This could be the moral equivalent of
	  chdir, i.e. it could set the folder for StandardFile.
	8 Please put this Icon on the desk and let me know if anything
	  gets dragged to it.  Think of an FTP server or printer for
	  this one: the user configures a printer or FTP drop and an
	  icon appears.  Dragging stuff to the icon causes "the right
	  thing" to happen.  How about a "backup" icon?  How about
	  inform me when an object is thrown in the trash?  When an
	  object is in the trash when it's emptied?
	- Message to turn off "subscriptions" like 1-5.
	- your idea here

Notice that there is already a defined data structure -- the
AppParmHandle -- that could be used for passing around selections.
There's even a convention -- ClrAppFiles() -- to indicate that
you've dealt with a particular file (see IM II p55ff.), so several
apps could be "signed up" for a command without harm.  There are
currently only two values for AppParmHandle's command field (open
and print) but clearly there's room for expansion there.

There's also more flexibility in the AppParmHandle structure than the
Finder currently uses (or every used): each file in the selection can
be in a different directory (each file has a vRefNum).  The FInder
has always restricted selections to a single directory, but there's no
reason that must be the case (except possible user confusion, an
important consideration).

This may not be the structures and architecture you want -- I am
shooting from the hip, so don't flame me, improve it!

=Ned Horvath=