A simple replacement for Pharo's native file/folder selection dialog.
- list of most common places (home, root, image directory, temp)
- custom bookmarks by dragging folders from file-pane to bookmark-pane
- toggle hidden files (right-click on file listing)
- preset file name
- filtering files by extensions or patterns and toggling between filters
- synchronous and asynchronous mode
(catalog soon)
Metacello new
baseline: 'FileDialog';
repository: 'github://peteruhnak/file-dialog/repository';
load.
If you feel brave, you can replace the native dialogs everywhere in the system by running
FDMorphicUIManager new beDefault
Of course you can switch back anytime you want.
MorphicUIManager new beDefault
If you chose using the extended UIManager, then you can use that
UIManager default chooseFileMatching: #('*.ston')
You can also use the classes directly — there are just minor differences in the behavior, such as DirectoryDialog
will not show files, etc.
FDSaveFileDialog
- saving a fileFDOpenFileDialog
- selecting a fileFDOpenDirectoryDialog
- selecting a directory
The user-facing API is in the api-customization
protocol of FDFileDialogPresenter
defaultFolder: aPath
— where should the dialog open, the default is the imageDirectorydefaultName: aString
— prefill the file name inputfiltersCustomization: aCollectionOfFDAbstractPredicate
— a collection of FDAbstractPredicateokActionBlock: aBlock
— a one arg block executed when a file was selectedpreviewer: aPreviewer
_ a son of FDAbstractPreviewer that returning a Spec widgetopenModal
— when you open the dialog as modal, you will get the selected value as a return instead of using the block
asynchronous — execute behavior on selection from a block
FDOpenFileDialog new
whenSelected: [ :file | file inspect ];
extensionFilters: {
'All images' -> #(jpg png gif svg).
'All files' -> #()
};
defaultFolder: FileLocator imageDirectory asFileReference;
open
synchronous — return the selected file as a value
file := FDOpenFileDialog new
openModal