links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
File choosing and saving dialogs
Last updated at 4:18 pm UTC on 21 December 2018
Rather than using UIManager default>request:initialAnswer: to ask a user for afilename, followed by much fiddling around, it would be nice to have a decent set of dialogs that provide a reasonable way to navigate the file system and choose a file to load or a file name to use for saving.

FileList, FileList2 and FileChooser all already exist and provide some faintly usable UI elements but 'messy' is only the beginning. To provide something simpler, cleaner and hopefully more useful we now have the FileChooserDialog, DirectoryChooserDialog and FileSaverDialog classes. Each provides a modal dialog that can be used directly or via the UIManager.

The simplest case is the DirectoryChooser, which simply provides a tree format view of the file system; the user selects a directory in the normal manner and if the 'accept' button is clicked the name of the directory is returned; otherwise nil is returned.

A FileChooserDialog provides a file system tree view and a multi-column list of the files within the selected directory. The user can select any file dhown - a list that may be restricted by a pattern set by assorted messages during the dialog construction. Generally a convenience method makes it simple to use a full file path to set the initial directory, the initial suggested file and the suffix to use as a pattern. This provides a simple interface to effectively match UIManager default> request:initialAnswer: in intent.

The FileSaverDialog adds a text field that mirros the selected filename BUT allows the user to type in a new name, thus providing a convenient way to save something to a new filename.

See FileAbstractSelectionDialog and subclasses for actual code and examples.

These classes are in the trunk 6.0alpha [1] image as of update 17544 but a not connected up to normal usage. To try out the dialogs, file in this -


And of course, report problems to the mail list.

[1] Squeak 6.0alpha was renamed to 5.2alpha.

See also

Dialog types