Professional Web Applications Themes

NSOpenPanel question - Mac Programming

Hi, I am a newbie programming a Cocoa app. I read in [url]http://developer.apple.com/doentation/UserExperience/Conceptual/AquaHIGuidelines/AHIGDialogs/chapter_6_section_3.html[/url] that "You can extend the Open dialog as appropriate for your application. For example, you could include a pop-up menu allowing users to filter the type of files that appear in the list (see Figure 6-5). Items that do not meet the filtering criteria would appear dimmed. The system creates a list of native file types supported by the application to populate the menu. You can supplement this list with custom types and specify the default to show when the dialog opens. You should include an All ...

  1. #1

    Default NSOpenPanel question

    Hi,

    I am a newbie programming a Cocoa app. I read in
    [url]http://developer.apple.com/doentation/UserExperience/Conceptual/AquaHIGuidelines/AHIGDialogs/chapter_6_section_3.html[/url]
    that
    "You can extend the Open dialog as appropriate for your application.
    For example, you could include a pop-up menu allowing users to filter
    the type of files that appear in the list (see Figure 6-5). Items that
    do not meet the filtering criteria would appear dimmed. The system
    creates a list of native file types supported by the application to
    populate the menu. You can supplement this list with custom types and
    specify the default to show when the dialog opens. You should include
    an All Applicable Files item, but it does not have to be the default."

    How can you do this. In my particular case, I just want to add a
    format selection (and I have the same question for a Save Panel).

    Thank you very much,

    Loc
    Loic BERTRAND Guest

  2. #2

    Default Re: NSOpenPanel question

    Loic BERTRAND <loic_e_bertrandyahoo.fr> wrote:
    > You can extend the Open dialog as appropriate for your application.
    > For example, you could include a pop-up menu allowing users to filter
    > the type of files that appear in the list (see Figure 6-5).
    > How can you do this.
    setAccessoryView. m.

    --
    matt neuburg, phd = [email]matttidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
    Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
    matt neuburg Guest

  3. #3

    Default Re: NSOpenPanel question

    [email]loic_e_bertrandyahoo.fr[/email] (Loic BERTRAND) wrote in message news:<4487c694.0309180127.2bd09b67posting.google. com>...
    > How can you do this. In my particular case, I just want to add a
    > format selection (and I have the same question for a Save Panel).
    With an NSSavePanel, you just add an accessory view with
    setAccessoryView.

    NSOpenPanel actually inherits from NSSavePanel (weird!)
    and so it works there, too.
    Eric Pepke Guest

  4. #4

    Default Re: NSOpenPanel question

    Thank you for these answers but actully it remains unclear for me:
    - how can I generate my accessory view (through a NIB object ?)
    - can I write a piece of code to generate one ?

    It would be great if one of you could send me a short extract showing
    practically how I can do this.

    Thank you very much,

    Loic
    Loic BERTRAND Guest

  5. #5

    Default Re: NSOpenPanel question

    In article <4487c694.0309190123.218b3665posting.google.com >,
    [email]loic_e_bertrandyahoo.fr[/email] (Loic BERTRAND) wrote:
    > Thank you for these answers but actully it remains unclear for me:
    > - how can I generate my accessory view (through a NIB object ?)
    > - can I write a piece of code to generate one ?
    Put it in a nib. You can create a raw view in a nib by dragging the
    CustomView object in Interface Builder directly into your nib file's
    window. This will create a view that isn't inside any windows or
    anything, and you can hook up an outlet to it like normal, then use that
    for your accessory view.

    You can, of course, always generate these things in code. But it's
    complicated. Look at NSView's and NSControl's headers and doentation
    to see how if you want to, but doing it in a nib is far better.
    Michael Ash Guest

  6. #6

    Default Re: NSOpenPanel question

    Loic BERTRAND <loic_e_bertrandyahoo.fr> wrote:
    > Thank you for these answers but actully it remains unclear for me:
    > - how can I generate my accessory view (through a NIB object ?)
    > - can I write a piece of code to generate one ?
    You can, sure. But an easier way is to make an NSView in your nib file
    and make a connection so that you can refer to it. Now when the time
    comes to put up your Open panel, use setAccessoryView to point it at
    that NSView. You interact with the stuff in the NSView through
    connections, just as you would any window or panel. m.

    --
    matt neuburg, phd = [email]matttidbits.com[/email], [url]http://www.tidbits.com/matt/[/url]
    Read TidBITS! It's free and smart. [url]http://www.tidbits.com[/url]
    matt neuburg Guest

  7. #7

    Default Re: NSOpenPanel question

    Thank you very much to all of you,

    It now works perfectly,

    Loic
    Loic BERTRAND Guest

  8. #8

    Default Re: NSOpenPanel question

    [email]loic_e_bertrandyahoo.fr[/email] (Loic BERTRAND) wrote in message news:<4487c694.0309190123.218b3665posting.google. com>...
    > Thank you for these answers but actully it remains unclear for me:
    > - how can I generate my accessory view (through a NIB object ?)
    > - can I write a piece of code to generate one ?
    I generally do short things like this by hand. NIB files are too
    annoying for any but the most common uses. Besides, if you
    need a NIB file, it probably means you're trying to put too much
    in there.

    Here's an example. It's just a single check box whereby the
    user can automatically create a subdirectory when saving a
    new project:

    savePanel = [NSSavePanel savePanel];
    dirSwitch = [NSButton alloc];
    [dirSwitch initWithFrame:rect];
    [dirSwitch setAutoresizingMask:NSViewWidthSizable |
    NSViewMaxYMargin | NSViewHeightSizable];
    [dirSwitch setTitle:[mainBundle
    localizedStringForKey:"HLPNewProj" value:nil table:"Help"]];
    [dirSwitch setToolTip:[mainBundle
    localizedStringForKey:"HLPNewProjTip" value:nil table:"Help"]];
    [dirSwitch setState:NSOnState];
    [dirSwitch setButtonType:NSSwitchButton];
    [dirSwitch setAutoresizingMask:NSViewWidthSizable];
    [savePanel setAccessoryView:dirSwitch];
    Eric Pepke Guest

  9. #9

    Default Re: NSOpenPanel question

    In article <ef37f531.0309201837.59f036a0posting.google.com >,
    [email]epepkeacm.org[/email] (Eric Pepke) wrote:
    > [email]loic_e_bertrandyahoo.fr[/email] (Loic BERTRAND) wrote in message
    > news:<4487c694.0309190123.218b3665posting.google. com>...
    > > Thank you for these answers but actully it remains unclear for me:
    > > - how can I generate my accessory view (through a NIB object ?)
    > > - can I write a piece of code to generate one ?
    >
    > I generally do short things like this by hand. NIB files are too
    > annoying for any but the most common uses. Besides, if you
    > need a NIB file, it probably means you're trying to put too much
    > in there.
    I beg to disagree. First, the code using the NSOpenPanel is probably a
    window controller, thus it probably already owns a nib where the view
    could be stashed easily. And how exactly are nib files "annoying"?
    Assuming you already have a nib that you're loading, you can load the
    view "for free" when you load the window, just by adding an outlet, no
    code needed. Even if you don't, it's a single line of code to load the
    nib and connect the view to your outlet. It's a lot shorter than your
    example code, and allows you to change things around a lot easier.
    Michael Ash Guest

Similar Threads

  1. Newbie Question: Biz Card Template Question
    By Thomas_Porter@adobeforums.com in forum Adobe Indesign Windows
    Replies: 4
    Last Post: May 30th, 08:08 AM
  2. Replies: 9
    Last Post: April 27th, 04:44 AM
  3. Pen Tool Use Question. (Embarrassingly Newbie Question)
    By Bozo Schmozo in forum Macromedia Flash
    Replies: 0
    Last Post: November 12th, 10:00 PM
  4. alert sheet after NSOpenPanel sheet
    By James W. Walker in forum Mac Programming
    Replies: 3
    Last Post: July 14th, 10:59 PM
  5. newB question: related tables question
    By Blue man in forum Microsoft SQL / MS SQL Server
    Replies: 1
    Last Post: June 30th, 04:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139