Up

NSSavePanel

Authors

Jonathan Gapen (jagapen@smithlab.chem.wisc.edu)
Nicola Pero (n.pero@mi.flashnet.it)
Mirko Viviani (mirko.viviani@rccr.cremona.it)
Standard panel for saving files

Copyright: (C) 1999, 2000 Free Software Foundation, Inc.


Contents -

  1. Software documentation for the NSSavePanel class
  2. Software documentation for the NSObject(NSSavePanelDelegate) informal protocol

Software documentation for the NSSavePanel class

NSSavePanel : NSPanel

Declared in:
AppKit/NSSavePanel.h
Standards:

Implements a panel that allows the user to save a file.

There is only one save panel per application and this panel is obtained by calling the +savePanel class method. From here, you should set the required file extension using -setRequiredFileType: When ready to show the panel, use the -runModal , or a similar method to show the panel in a modal session. Other methods allow you to set the initial directory and initially choosen file. The method will return one of NSOKButton or NSCancelButton depending on which button the user pressed.

Use the -filename method to retrieve the name of the file the user choose.


Instance Variables

Method summary

savePanel 

+ (NSSavePanel*) savePanel;

Returns the shared NSSavePanel instance


URL 

- (NSURL*) URL;

Description forthcoming.


accessoryView 

- (NSView*) accessoryView;

Returns the accesory view (if any).


allowedFileTypes 

- (NSArray*) allowedFileTypes;

Description forthcoming.


allowsOtherFileTypes 

- (BOOL) allowsOtherFileTypes;

Description forthcoming.


beginSheetForDirectory: file: modalForWindow: modalDelegate: didEndSelector: contextInfo: 

- (void) beginSheetForDirectory: (NSString*)path file: (NSString*)filename modalForWindow: (NSWindow*)docWindow modalDelegate: (id)delegate didEndSelector: (SEL)didEndSelector contextInfo: (void*)contextInfo;

Description forthcoming.


canCreateDirectories 

- (BOOL) canCreateDirectories;

Description forthcoming.


canSelectHiddenExtension 

- (BOOL) canSelectHiddenExtension;

Description forthcoming.


cancel: 

- (void) cancel: (id)sender;

Description forthcoming.


directory 

- (NSString*) directory;

Returns the directory choosen by the user. Do not invoke directory within a modal loop because the information that these methods fetch is updated only upon return.


filename 

- (NSString*) filename;

Returns the absolute filename choosen by the user. Do not invoke filename within a modal loop because the information that these methods fetch is updated only upon return.


isExpanded 

- (BOOL) isExpanded;

Description forthcoming.


isExtensionHidden 

- (BOOL) isExtensionHidden;

Description forthcoming.


message 

- (NSString*) message;

Description forthcoming.


nameFieldLabel 

- (NSString*) nameFieldLabel;

Description forthcoming.


ok: 

- (void) ok: (id)sender;

Description forthcoming.


prompt 

- (NSString*) prompt;

Returns the prompt used in the current path field.


requiredFileType 

- (NSString*) requiredFileType;

Returns the required file type. The default, indicated by empty string, is no required file type.


runModal 

- (int) runModal;

Shows the save panel for the user. This method invokes -runModalForDirectory:file: with empty strings for the filename. Returns NSOKButton (if the user clicks the OK button) or NSCancelButton (if the user clicks the Cancel button).


runModalForDirectory: file: 

- (int) runModalForDirectory: (NSString*)path file: (NSString*)filename;

Initializes the panel to the directory specified by path and, optionally, the file specified by filename, then displays it and begins its modal event loop; path and filename can be empty strings. The method invokes [NSApplication:-runModalForWindow:] method with self as the argument. Returns NSOKButton (if the user clicks the OK button) or NSCancelButton (if the user clicks the Cancel button). If path is nil then the panel displays the last selected directory or as a last resort, the current working directory.


runModalForDirectory: file: relativeToWindow: 

- (int) runModalForDirectory: (NSString*)path file: (NSString*)filename relativeToWindow: (NSWindow*)window;

Description forthcoming.


selectText: 

- (void) selectText: (id)sender;

Description forthcoming.


setAccessoryView: 

- (void) setAccessoryView: (NSView*)aView;

Sets an accessory view which is shown near the bottom of the panel. The panel is automatically expanded with enough room to show the extra view. You can use this extra view to customize various characteristics of the file selection mechanism. For instance you could add a popup button which allows the user to select the format that the file is saved in (e.g. rtf or txt). See also -validateVisibleColumns .


setAllowedFileTypes: 

- (void) setAllowedFileTypes: (NSArray*)types;

Description forthcoming.


setAllowsOtherFileTypes: 

- (void) setAllowsOtherFileTypes: (BOOL)flag;

Description forthcoming.


setCanCreateDirectories: 

- (void) setCanCreateDirectories: (BOOL)flag;

Description forthcoming.


setCanSelectHiddenExtension: 

- (void) setCanSelectHiddenExtension: (BOOL)flag;

Description forthcoming.


setDirectory: 

- (void) setDirectory: (NSString*)path;

Sets the current path name in the Save panel's browser. The path argument must be an absolute path name.


setExtensionHidden: 

- (void) setExtensionHidden: (BOOL)flag;

Description forthcoming.


setMessage: 

- (void) setMessage: (NSString*)message;

Description forthcoming.


setNameFieldLabel: 

- (void) setNameFieldLabel: (NSString*)label;

Description forthcoming.


setPrompt: 

- (void) setPrompt: (NSString*)prompt;

Returns the prompt of the Save panel field that holds the current pathname or file name. By default this prompt is 'Name: '.


setRequiredFileType: 

- (void) setRequiredFileType: (NSString*)fileType;

Specifies the type, a file name extension to be appended to any selected files that don't already have that extension; The argument type should not include the period that begins the extension. Invoke this method each time the Save panel is used for another file type within the application. If you do not invoke it, or set it to empty string or nil, no extension will be appended, indicated by an empty string returned from -requiredFileType .


setTitle: 

- (void) setTitle: (NSString*)title;

Sets the title of the NSSavePanel to title. By default, 'Save' is the title string. If you adapt the NSSavePanel for other uses, its title should reflect the user action that brings it to the screen.


setTreatsFilePackagesAsDirectories: 

- (void) setTreatsFilePackagesAsDirectories: (BOOL)flag;

Sets the NSSavePanel's behavior for displaying file packages (for example, MyApp.app) to the user. If flag is YES, the user is shown files and subdirectories within a file package. If NO, the NSSavePanel shows each file package as a file, thereby giving no indication that it is a directory.


title 

- (NSString*) title;

Returns the title of the save panel


treatsFilePackagesAsDirectories 

- (BOOL) treatsFilePackagesAsDirectories;

Returns YES if file packages are shown as directories. The default is NO.


validateVisibleColumns 

- (void) validateVisibleColumns;

Validates and possibly reloads the browser columns that are visible in the Save panel by causing the delegate method -panel:shouldShowFilename: to be invoked. One situation in which this method would find use is whey you want the browser to show only files with certain extensions based on the selection made in an accessory-view pop-up list. When the user changes the selection, you would invoke this method to revalidate the visible columns.




Instance Variables for NSSavePanel Class

_OKButtonPressed

@protected BOOL _OKButtonPressed;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_accessoryView

@protected NSView* _accessoryView;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_allowsOtherFileTypes

@protected BOOL _allowsOtherFileTypes;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_bottomView

@protected NSView* _bottomView;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_browser

@protected NSBrowser* _browser;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_canCreateDirectories

@protected BOOL _canCreateDirectories;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_canSelectHiddenExtension

@protected BOOL _canSelectHiddenExtension;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_delegateHasCompareFilter

@protected BOOL _delegateHasCompareFilter;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_delegateHasDirectoryDidChange

@protected BOOL _delegateHasDirectoryDidChange;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_delegateHasSelectionDidChange

@protected BOOL _delegateHasSelectionDidChange;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_delegateHasShowFilenameFilter

@protected BOOL _delegateHasShowFilenameFilter;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_delegateHasUserEnteredFilename

@protected BOOL _delegateHasUserEnteredFilename;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_delegateHasValidNameFilter

@protected BOOL _delegateHasValidNameFilter;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_directory

@protected NSString* _directory;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_form

@protected NSForm* _form;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_fullFileName

@protected NSString* _fullFileName;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_isExtensionHidden

@protected BOOL _isExtensionHidden;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_okButton

@protected NSButton* _okButton;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_originalMinSize

@protected NSSize _originalMinSize;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_originalSize

@protected NSSize _originalSize;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_requiredFileType

@protected NSString* _requiredFileType;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_titleField

@protected NSTextField* _titleField;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_topView

@protected NSView* _topView;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.


_treatsFilePackagesAsDirectories

@protected BOOL _treatsFilePackagesAsDirectories;

Warning the underscore at the start of the name of this instance variable indicates that, even though it is not technically private, it is intended for internal use within the package, and you should not use the variable in other code.





Software documentation for the NSObject(NSSavePanelDelegate) informal protocol

NSObject(NSSavePanelDelegate)

Declared in:
AppKit/NSSavePanel.h
Standards:

Description forthcoming.

Method summary

panel: compareFilename: with: caseSensitive: 

- (NSComparisonResult) panel: (id)sender compareFilename: (NSString*)filename1 with: (NSString*)filename2 caseSensitive: (BOOL)caseSensitive;

Description forthcoming.


panel: directoryDidChange: 

- (void) panel: (id)sender directoryDidChange: (NSString*)path;

Description forthcoming.


panel: isValidFilename: 

- (BOOL) panel: (id)sender isValidFilename: (NSString*)filename;

The NSSavePanel sends this message just before the end of a modal session for each file name displayed or selected (including file names in multiple selections). The delegate determines whether it wants the file identified by filename; it returns YES if the file name is valid, or NO if the NSSavePanel should stay in its modal loop and wait for the user to type in or select a different file name or names. If the delegate refuses a file name in a multiple selection, none of the file names in the selection are accepted.


panel: shouldShowFilename: 

- (BOOL) panel: (id)sender shouldShowFilename: (NSString*)filename;

Sent by NSSavePanel to check whether a file should be displayed in the panel or not. The filename argument is the complete path to the file.


panel: userEnteredFilename: confirmed: 

- (NSString*) panel: (id)sender userEnteredFilename: (NSString*)fileName confirmed: (BOOL)okFlag;

Description forthcoming.


panel: willExpand: 

- (void) panel: (id)sender willExpand: (BOOL)expanding;

Description forthcoming.


panelSelectionDidChange: 

- (void) panelSelectionDidChange: (id)sender;

Description forthcoming.



Up