Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Q]: Nav Services How To Default to "All Documents?"



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:email@hidden>
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.