jon@druco.ATT.COM (GotowJK) (04/12/89)
I'm writing a little program that needs to prompt the user to select a directory using SFGetFile. I once saw a DA (Virus Detective) that did just this, and have a question about how one implements a "Directory" button. Currently, I'm adding a custom "Directory" button to SFGetFile which allows the user to return the selected directory name. (ie. "Open" descends into the directory while "Directory" returns with the selected directory name). My current routine (quite a hack) installs a dialog filter proc using SFPGetFile. It looks for a hit on the "Directory" button, returning an "Open" and then a "Cancel" to the SFGetFile filter proc when it gets one. This effectively descends into the selected directory and then exits, so I can subsequently use the values in the SFSaveDisk and CurDirStore globals to find out what the selected directory was. This works, but is a bit unsightly since the user actually sees the SFGetFile dialog descending into the selected directory before quitting. How do I do this smoothly?? Is there another system global (which I know I'm not supposed to use) which points to the selected string in the SFGetFile dialog? Will the author of Virus Detective help me out on this one? I don't remember his code doing this (though I guess I could've just missed it - no, any _good_ programmer could think up a better way :-) Thanks, Jon Gotow AT&T Bell Labs - Middletown, NJ ARPANET jon@druco.att.com USENET att!druco!jon
jon@druco.ATT.COM (GotowJK) (04/13/89)
Whoops. In <4064@druco.ATT.COM> I wrote: >I'm writing a little program that needs to prompt the user to select a >directory using SFGetFile. I once saw a DA (Virus Detective) that did >just this, and have a question about how one implements a "Directory" >button. > >Currently, I'm adding a custom "Directory" button to SFGetFile which >allows the user to return the selected directory name. (ie. "Open" >descends into the directory while "Directory" returns with the selected >directory name). My current routine (quite a hack) installs a dialog >filter proc using SFPGetFile. It looks for a hit on the "Directory" >button, returning an "Open" and then a "Cancel" to the SFGetFile filter >proc when it gets one. This effectively descends into the selected > (ETC.) I just went back and read Technote 80 again (very red face :-). In the first few lines, it states that if SFReply.good is false, SFReply.fType contains the ref num of the last selected directory from the SFGetFile box. The above gyrations are not at all necessary. One simply has to look at the reply record to find out what the directory is. I should stop programming late at night - this one walked right by me the first time (practically kicked me in the face, too). Sorry to add traffic to the net. Thanks, Jon Gotow ------------------------------------------------------------------------ Jon Gotow - Physical Designer AT&T Bell Labs General Business Systems Group 200 Laurel Avenue ARPA: jon@druco.att.com Middletown, NJ 07748 UUCP: att!druco!jon Disclaimer: As always, the opinions stated here have nothing whatsoever to do with my employer.
jln@accuvax.nwu.edu (John Norstad) (04/13/89)
I have a reusable module named getff.c that does exactly this - it lets the user pick either a file or a folder. By passing the proper parameters you can get rid of the files and list only folders, if that's what you want. Write to me if you'd like a copy. I wrote the stupid thing a few months ago, so of course I've already forgotten how it works (I remember it was pretty ugly). But it does work! John Norstad Academic Computing and Network Services Northwestern University Bitnet: jln@nuacc Internet: jln@acns.nwu.edu AppleLink: a0173 CompuServe: 76666,573
tim@hoptoad.uucp (Tim Maroney) (04/14/89)
In article <4064@druco.ATT.COM> jon@druco.ATT.COM (GotowJK) writes: >I'm writing a little program that needs to prompt the user to select a >directory using SFGetFile. I just posted a long message on doing this a few days ago. Did you see it? I only ask because USENET reliability seemes to be suffering a further decline. >It looks for a hit on the "Directory" >button, returning an "Open" and then a "Cancel" to the SFGetFile filter >proc when it gets one. This effectively descends into the selected >directory and then exits, so I can subsequently use the values in the >SFSaveDisk and CurDirStore globals to find out what the selected >directory was. Notice this approach does not allow specification of a volume top-level as the desired directory. >How do I do this smoothly?? Is there another system global (which I >know I'm not supposed to use) which points to the selected string in >the SFGetFile dialog? No, but if you'll look at Inside Mac volume IV, you'll see that the directory id is stashed in the fType field of the reply record. Your item filter can easily stash this field in a program global and you can then use it after returning from SFPGetFile. However, I think that Mac developers ought to standardize on using the *current* directory rather than the *selected* directory when a directory is chosen using SFPGetFile. This approach is more general, can be idiot-proofed (by disabling the "Folder" button when a folder is selected in the list), and in my opinion is more intuitive. Finally, please remember that "Directory" is a jargon term that should not appear in your user interface! Use the term "Folder" instead. -- Tim Maroney, Consultant, Eclectic Software, sun!hoptoad!tim "I was brought up in the other service; but I knew from the first that the Devil was my natural master and captain and friend. I saw that he was in the right, and that the world cringed to his conqueror only from fear." - Shaw, "The Devil's Disciple"