Adding an additional view to the NSDocument save pane in addition to its own file type popup button

I have an application based on NSDocument that can be saved for several file types, so when saving a document, NSDocument helps to add a popup to the save panel as an auxiliary view that allows the user to select the type that d would like to save as. Nice.

Now I have another view that I would like to include in the save panel, but if I just override -[NSDocument prepareSavePanel:] and use -setAccessoryView: to insert my own view, it replaces the popup name of the file type, therefore only appears on the save panel my view, not the popup button.

Is there a way that NSDocument provides the simultaneous display of both my own view and the pop-up type of its type in the save panel? It looks like I could grab the existing kind of accessories, fix it along with my own accessory in the form of a container and return it back, but it looks pretty hacky and I was wondering if there is a better way to do this that I missed.

+4
source share
1 answer

No, not much better. It might be a little simpler / nicer:

  • Create a file type in the pop-up window of your nib accessory
  • At runtime, locate the popup of an existing NSSavePanel accessory,
  • Call setTarget: / setAction: / setMenu: on your popup menu with arguments extracted from how the existing popup was set.

The way our application does something and simplifies the visual positioning of a file type popup with the rest of the controls, since all this is in the same nib.

+4
source

All Articles