Professional Web Applications Themes

[Q]: Nav Services Default File Type Selection? - Mac Programming

hello there, first of all, i have a Rez source file that defines an 'nsMI' resource as follows: //************************************************** ********************* ** type 'nsMI' // NavMenuItemSpec { wide array { integer = 0; // version literal longint; // menuCreator literal longint; // menuType pstring[255]; // menuItemname fill byte[245]; // reserved[245] align word; }; }; //************************************************** ********************* ** resource 'nsMI' (2000) { { '????', 'TIFF', "TIFF"; '????', 'PICT', "Macintosh PICT"; } } then in my code, i want to create an "Open File" dialog that adds these 2 file types to the "Show" popup, along with an "All Doents" menu item. so, ...

  1. #1

    Default [Q]: Nav Services Default File Type Selection?

    hello there,

    first of all, i have a Rez source file that defines an 'nsMI' resource
    as follows:

    //************************************************** *********************
    **
    type 'nsMI' // NavMenuItemSpec
    {
    wide array
    {
    integer = 0; // version
    literal longint; // menuCreator
    literal longint; // menuType
    pstring[255]; // menuItemname
    fill byte[245]; // reserved[245]
    align word;
    };
    };

    //************************************************** *********************
    **
    resource 'nsMI' (2000)
    {
    {
    '????', 'TIFF', "TIFF";
    '????', 'PICT', "Macintosh PICT";
    }
    }

    then in my code, i want to create an "Open File" dialog that adds these
    2 file types to the "Show" popup, along with an "All Doents" menu
    item. so, this is what i do:

    theNSMISpecH = ( NavMenuItemSpecArrayHandle ) GetResource( 'nsMI', 2000
    );
    theErr = ResError();
    if( theErr == noErr )
    {
    // get default NS dialog options...
    NavGetDefaultDialogOptions( &theNSDialogOptions );

    // don't auto-translate on open...
    theNSDialogOptions.dialogOptionFlags |= kNavDontAutoTranslate;

    // don't add translatable file items...
    theNSDialogOptions.dialogOptionFlags |= kNavDontAddTranslateItems;

    // allow multiple file selections...
    theNSDialogOptions.dialogOptionFlags |= kNavAllowMultipleFiles;

    // display "All Files" in "Show" popup...
    theNSDialogOptions.dialogOptionFlags |= kNavAllFilesInPopup;

    // install our "Show" popup extension...
    theNSDialogOptions.popupExtension = theNSMISpecH;

    // create a reference to our NS event-handling proc...
    theNSEventProc = NewNavEventUPP( MyNSOpenEventProc );

    // create a reference to our NS file-filtering proc...
    theNSFilterProc = NewNavObjectFilterUPP( MyNSOpenFilterProc );

    // invoke NS "Get File" dialog...
    theErr = NavGetFile( NULL, &theNSReply, &theNSDialogOptions,
    theNSEventProc, NULL, theNSFilterProc, NULL, &theDlogInfo );

    // post-processing here...

    and here's a snippet from my event-handling proc for this dialog:

    pascal void MyNSOpenEventProc( NavEventCallbackMessage theCBSelector,
    NavCBRecPtr theCBParams, NavCallBackUserData theCBUserData )
    {
    if( ( theCBParams != NULL ) && ( theCBUserData != NULL ) )
    {
    switch( theCBSelector )
    {
    case kNavCBStart:
    NavCustomControl( theCBParams->context,
    kNavCtlSelectCustomType, myDefNavMenuItemSpecPtr );
    break;

    // ...etc.

    now, assume that 'myDefNavMenuItemSpecPtr' is a global ptr to one of the
    NavMenuItemSpec elements that i pull out of my 'nsMI' resource shown
    above. making this call to NavCustomControl() will set the "Show" popup
    to the appropriate file type.

    my question is, that's all well and good, but what if i want to make the
    "All Doents" item the default selected item when the "Open File"
    dialog appears instead of one of my "custom" types that i've specified
    in the 'popupExtension' field of the NavDialogOptions structure? in my
    open dialog, the "All Doents" menu item is shown as the last item in
    the list. but i don't know how to get Nav Services to select that "All
    Doents" item by default in the 'kNavCBStart' case?

    to clarify, i've tried calling:

    NavCustomControl( theCBParams->context, kNavCtlSelectAllType,
    kNavAllFiles );

    ....to no avail, i can't seem to figure out what the correct procedure
    would be, if there even is one? i've noticed that when i select the "All
    Doents" item, my event proc gets a NavMenuItemSpec element that looks
    like this:

    menuCreator: 0
    menuType: 0
    menuItemName: "\pAll Doents"

    ....so i've even tried setting my global 'myDefNavMenuItemSpecPtr' global
    to those values, and it still seems to just default to the first
    "custom" type that i've set to the 'popupExtension' field, in this case,
    'TIFF'.

    i notice that Photoshop 7 seems to be able to do this, so i know it's
    possible, i'm just not sure where i'm going wrong here. if someone could
    please point me in the right direction, it'd be much appreciated. thanks!

    ---
    Phillip Kavan <mailto:kavan_macdls.net>
    Phillip Kavan Guest

  2. #2

    Default Re: [Q]: Nav Services Default File Type Selection?

    > what if i want to make the
    > "All Doents" item the default selected item when the "Open File"
    > dialog appears instead of one of my "custom" types that i've specified
    > in the 'popupExtension' field of the NavDialogOptions structure?
    You need to install a Custom Event Proc which responds to the kNavCBStart
    event (when the dialog is being shown), which switches the popup
    to the item you want.

    Here's mine for "All Readable Files":

    static pascal void
    MyNavEventProc(NavEventCallbackMessage inSelector,
    NavCBRecPtr ioParams,
    NavCallBackUserData /*callBackUD*/){



    switch (inSelector){
    try{
    case kNavCBStart:
    SInt16 theKind = kNavAllReadableFiles; //change the popup
    menu to "all readable"
    ::NavCustomControl(ioParams->context, kNavCtlSelectAllType,
    &theKind);
    break;



    }
    catch(...) {} // Can't throw back through the Toolbox
    }

    Now, if you could figure out how to change the title of the extra
    items in the popup that say "All Known Doents" and "All Readable
    Doents" to something more understandable under OSX, I'd be
    appreciative.... :)


    david
    david ralley Guest

  3. #3

    Default Re: [Q]: Nav Services Default File Type Selection?

    OK cool, that works...thanks!

    Last question...how do i get the "All Readable Doents" to show up if
    i'm using the 'popupExtension' method? i only get "All Doents," and
    only after i specify the 'kNavAllFilesInPopup' flag in the dialogOptions.

    do you only get the "All Readable Doents" if you use a TypeList
    handle? (i'm not using one...)

    In article
    <ralley.2-0AE6FE.08543928082003charm.magnus.acs.ohio-state.edu>,
    david ralley <ralley.2osu.edu> wrote:
    > > what if i want to make the
    > > "All Doents" item the default selected item when the "Open File"
    > > dialog appears instead of one of my "custom" types that i've specified
    > > in the 'popupExtension' field of the NavDialogOptions structure?
    >
    > You need to install a Custom Event Proc which responds to the kNavCBStart
    > event (when the dialog is being shown), which switches the popup
    > to the item you want.
    >
    > Here's mine for "All Readable Files":
    >
    > static pascal void
    > MyNavEventProc(NavEventCallbackMessage inSelector,
    > NavCBRecPtr ioParams,
    > NavCallBackUserData /*callBackUD*/){
    >
    >
    >
    > switch (inSelector){
    > try{
    > case kNavCBStart:
    > SInt16 theKind = kNavAllReadableFiles; //change the popup
    > menu to "all readable"
    > ::NavCustomControl(ioParams->context, kNavCtlSelectAllType,
    > &theKind);
    > break;
    >
    >
    >
    > }
    > catch(...) {} // Can't throw back through the Toolbox
    > }
    >
    > Now, if you could figure out how to change the title of the extra
    > items in the popup that say "All Known Doents" and "All Readable
    > Doents" to something more understandable under OSX, I'd be
    > appreciative.... :)
    >
    >
    > david
    Phillip Kavan Guest

Similar Threads

  1. making php the default file type
    By drbb in forum Macromedia Contribute General Discussion
    Replies: 1
    Last Post: May 9th, 04:32 PM
  2. CGI popup_menu does not change default selection
    By Yuri Shtil in forum PERL Modules
    Replies: 6
    Last Post: March 30th, 11:06 PM
  3. Replies: 5
    Last Post: October 24th, 06:38 PM
  4. Replies: 3
    Last Post: October 18th, 06:56 AM
  5. Replies: 2
    Last Post: October 16th, 08:29 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