ADC Home > Reference Library > Technical Q&As > Carbon > Human Interface Toolbox >

How can I set the default location with the modern Navigation APIs NavCreatexxx?


Q: I was using the defaultLocation parameter when I was calling NavGetFile(), NavPutFile(), etc., but this parameter disappeared in the new APIs NavCreateGetFileDialog(), NavCreatePutFileDialog(), etc., how can I set the default location in a modern way?

A: You just need to use the NavCustomControl call using the kNavCtlSetLocation message as early as possible after you call NavDialogRun(). The best way is to have this code when you get the kNavCBStart selector in your Event Proc, the following source code excerpt illustrate this:



 pascal void modernEventProc(NavEventCallbackMessage callBackSelector,
                            NavCBRecPtr callBackParms, void* callBackUD)
  {
  ...
  switch(callBackSelector)
    {
    ...
    case kNavCBStart:
      {
      OSStatus theStatus = noErr;
      AEDesc theLocation = {typeNull, NULL);
      FSSpec theFSSpec;
      theStatus = FSMakeFSSpec(...<your construction here>..., &theFSSpec);
      if (theStatus != noErr) {... your error handling here ...}
      theStatus = AECreateDesc(typeFSS, &theFSSpec, sizeof(FSSpec), &theLocation));
      if (theStatus != noErr) {... your error handling here ...}
      theStatus = NavCustomControl(callBackParms->context,
                        kNavCtlSetLocation, (void*)&theLocation);
      if (theStatus != noErr) {... your error handling here ...}
      }
    ...
    }
  ...
  }

Listing 1. Setting the location in the kNavCBStart selector of the Event Proc




[Jul 01 2002]


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.