[comp.sys.next] OpenPanel for Directories

songer@orchestra.ecn.purdue.edu (Christopher M Songer) (06/26/91)

OK,
     It must be in the docs somewhere and I can't find it. I want
an OpenPanel to allow the return of a filename which is a directory.
I don't want the contents of the directory shown when the user 
selects it. The directory name does have a unique extension.
How do I do this? (WriteNow does it sometimes... why can't I?)

Thanks!
-Chris

pfkeb@kaon.SLAC.Stanford.EDU (Paul Kunz) (06/26/91)

In article <1991Jun25.195535.8745@noose.ecn.purdue.edu> songer@orchestra.ecn.purdue.edu (Christopher M Songer) writes:


	It must be in the docs somewhere and I can't find it. I want
   an OpenPanel to allow the return of a filename which is a directory.
   I don't want the contents of the directory shown when the user 
   selects it. The directory name does have a unique extension.
   How do I do this? (WriteNow does it sometimes... why can't I?)

   Thanks!
   -Chris


First step is to declare your unique filename extension for your app
with the project/attributes like you would for a plain file.   Then
you must install you app in ~/Apps or /LocalApps for it to take
effect.   Then you can go back to debugging your app and the openPanel
should show your directory as if it were a file.

By chance, I happened to do this procedure for the first time this
weekend.

eahb@vi.ri.cmu.edu (Edwin Blackwood) (06/26/91)

In article <1991Jun25.195535.8745@noose.ecn.purdue.edu> songer@orchestra.ecn.purdue.edu (Christopher M Songer) writes:
>OK,
>     It must be in the docs somewhere and I can't find it. I want
>an OpenPanel to allow the return of a filename which is a directory.
>I don't want the contents of the directory shown when the user 
>selects it. The directory name does have a unique extension.
>How do I do this? (WriteNow does it sometimes... why can't I?)
>
>Thanks!
>-Chris

You need to declare the types of extensions your app will look for in the
open panel -- like this:

    static const char *openTypes[] = {"ext1", "ext2", NULL};
        // do not include the ".", ie "wn", not ".wn"
    id openPanel = [OpenPanel new];
    static char dir[MAXPATHLEN+1];
    static char file[MAXPATHLEN+1]

    // decide what directory and file you want to default the open panel to
    if ([openPanel runModalForDirectory:dir file:file types:openTypes]) {
        //do your thing 
    } else {
        // can't do your thing because openPanel failed or was canceled
    }

Hope this helps.

Ed Blackwood
eahb@visus.com

Software Engineer: Visual Understanding Systems, Inc. (VISUS).  Developers of
PaperSight - the only integrated document image management system for the NeXT

wb1j+@andrew.cmu.edu (William M. Bumgarner) (06/27/91)

If you want the Workspace Manager to recognize your folders and files
owned by your application (as Mail does with .mbox folders) you need to:

In Interface builder:

 - look at the project inspector and switch to the 'attribute editor'
 - click on the first document icon
 - fill in the extension field w/your extension.  Do not put the period
in-- just the letters of your extension

Outside of IB:
 - make install -- this will compile, strip and install your app in ~/Apps/
 - log out and log back in;  Workspace should recognize your files now...

b.bum


b.bumgarner            | Disclaimer:  All opinions expressed are my own.
wb1j+@andrew.cmu.edu   | I officially don't represent anyone unless I
NeXT Campus Consultant | explicity say I am doing so. So there. <Thpppt!>
"I ride tandem with the random/Things don't run the way I planned them.."