Ask a Question related to Mac Programming, Design and Development.
-
Phillip Kavan #1
[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
-
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... -
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... -
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... -
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"... -
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... -
david ralley #2
Re: [Q]: Nav Services Default File Type Selection?
> what if i want to make the
You need to install a Custom Event Proc which responds to the kNavCBStart> "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?
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
-
Phillip Kavan #3
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.... :)
>
>
> davidPhillip Kavan Guest



Reply With Quote

