Return to the Alphabetic Index
Return to the Class Browser
Return to the Picture Browser
Copyright (c) 1994 by NeXT Computer, Inc. All Rights
Reserved.
NSOpenPanel
Inherits From: NSSavePanel : NSPanel : NSWindow : NSResponder :
NSObject
Conforms To: NSCoding (NSResponder)
NSObject (NSObject)
Declared In: AppKit/NSOpenPanel.h
Class Description
NSOpenPanel provides the Open panel of the OpenStep user interface.
Applications use the Open panel as a convenient way to query the user for the
name of a file to open. The Open panel can only be run modally.
Most of this class's behavior is defined by its superclass, NSSavePanel.
NSOpenPanel adds to this behavior by:
. Letting you specify the types (by file-name extension) of the items that will
appear in the panel
. Letting the user select files, directories, or both
. Letting the user select multiple items at a time
Typically, you access an NSOpenPanel by invoking the openPanel method.
When the class receives an openPanel message, it tries to reuse an
existing panel rather than create a new one. If a panel is reused, its
attributes are reset to the default values so that the effect is the same as
receiving a new panel. Because Open panels may be reused, you shouldn't modify
the instance returned by openPanel, except through the methods listed
below (and those inherited from its superclass, NSSavePanel). For example, you
can set the panel's title and whether it allows multiple selection, but not the
arrangement of the buttons within the panel. If you must modify the Open panel
substantially, create and manage your own instance using the alloc...
and init... methods rather than the openPanel method.
Accessing the NSOpenPanel
- + (NSOpenPanel *)openPanel Returns an NSOpenPanel object having default
initialization.
Filtering Files
- - (BOOL)allowsMultipleSelection Returns YES if the panel allows the user
to open multiple files (and directories) at a time.
- - (BOOL)canChooseDirectories Returns YES if the panel allows the user to
choose directories.
- - (BOOL)canChooseFiles Returns YES if the panel allows the user to
choose files.
- - (void)setAllowsMultipleSelection:(BOOL)flag Sets whether the
user can open multiple files (and directories) at a time.
- - (void)setCanChooseDirectories:(BOOL)flag Sets whether the user
can choose directories.
- - (void)setCanChooseFiles:(BOOL)flag Sets whether the user can
choose files.
Querying the Chosen Files
- - (NSArray *)filenames Returns an array containing the names of the
selected files and directories.
Running the NSOpenPanel
- - (int)runModalForTypes:(NSArray *)fileTypes Invokes the
runModalForDirectory:file:types: method, using the last directory from
which a file was chosen as the path argument. Returns the value returned by
that method.
- - (int)runModalForDirectory:(NSString *)path Displays the panel
and begins its event loop. The panel
file:(NSString *)filename displays the files in path that
match the types in
types:(NSArray *)fileTypes fileTypes (an array of
NSString objects), with filename selected. Returns NSOKButton (if the
user clicks the OK button) or NSCancelButton (if the user clicks the Cancel
button).