[Q]: Nav Services Default File Type Selection?

Ask a Question related to Mac Programming, Design and Development.

  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 Documents" 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 Documents" 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 Documents" 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
    Documents" 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
    Documents" item, my event proc gets a NavMenuItemSpec element that looks
    like this:

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

    ....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_mac@dls.net>
    Phillip Kavan Guest

  2. Similar Questions and Discussions

    1. making php the default file type
      I've got a client set up to use Contribute to edit a PHP site. When he creates a new page, the default file extension is .htm and it needs to be...
    2. CGI popup_menu does not change default selection
      Hi, According to the doc, -default argument to popup_menu sets the default selection. It does not seem to work for me. I carefully examined the...
    3. How to populate <input type=file...> with default value?
      Is there some way to populate the "Browse" box for a <input type=file...> with a default value? I can do it for <input type=text...>, but can't...
    4. HowTo Send Uploaded File with INPUT Type file to Sql Server Image Data Type ?
      I have the following problem: I have the following form client side: <FORM.......> <FORM action="./WZUpload.asp" method="Post"...
    5. Selection List from Database with default value
      I have a form which has a dropdown box created from a MySQL database. The first value is displayed in the box and clicking on the down arrow shows...
  3. #2

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

    > what if i want to make the
    > "All Documents" 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 Documents" and "All Readable
    Documents" to something more understandable under OSX, I'd be
    appreciative.... :)


    david
    david ralley Guest

  4. #3

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

    OK cool, that works...thanks!

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

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

    In article
    <ralley.2-0AE6FE.08543928082003@charm.magnus.acs.ohio-state.edu>,
    david ralley <ralley.2@osu.edu> wrote:
    > > what if i want to make the
    > > "All Documents" 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 Documents" and "All Readable
    > Documents" to something more understandable under OSX, I'd be
    > appreciative.... :)
    >
    >
    > david
    Phillip Kavan Guest

Posting Permissions

  • You may not post new threads
  • You may 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