FileChooser Utility Class
Description
In BBj 12.0 and higher, the FileChooser utility class is a BBj custom class that acts as a wrapper around the BBjFileChooser. It uses group namespace variables for returning results.
Public ConstructorsFileChooser(BBjString startDir$, BBjString nsVar$) FileChooser(BBjString startDir$, BBjString nsVar$) FileChooser(BBjString startDir$, BBjString nsVar$, BBjNumber useClient) FileChooser(BBjString startDir$, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly) FileChooser(BBjString startDir$, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel) FileChooser(BBjString startDir$, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel, BBjNumber useSaveDialog) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel, BBjNumber useSaveDialog) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel, BBjNumber useSaveDialog) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel, BBjNumber useSaveDialog, BBjString filtername$, BBjstring filter$) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel, BBjNumber useSaveDialog, BBjString filtername$, BBjVector filters!) FileChooser(BBjString startDir$, BBjNumber startX, BBjNumber startY, BBjString nsVar$, BBjNumber useClient, BBjNumber dirOnly, BBjNumber multiSel, BBjNumber useSaveDialog, BBjVector filterVectMap!) |
Variable |
Description |
---|---|
startDir$ |
Instructs the file chooser to first navigate to this directory. |
startX |
Left coordinate at which to position the dialog or -1 (default) to have dialog centered horizontally. |
startY |
Upper coordinate at which to position the dialog or -1 (default) to have the dialog centered vertically. |
nsVar$ |
Group namespace variable name in which to return the resultant selection and the base name in which to return the user’s action. |
useClient |
Flags whether to use the server (default) or client file system. |
dirOnly |
Flags whether only directories are allowed or files (default). |
multiSel |
Flags whether multiple selections may be made or only one selection (default). |
useSaveDialog |
Flags whether a save dialog instead of open dialog (default) should be displayed. |
filtername$ |
Description of file filter or an empty string (default) for all file types. |
filter$ |
File filter definition or an empty string (default) for all file types. |
filters! |
BBjVector of file filters. |
filterVectMap! |
BBjVector of hash maps containing filter names their BBjVector of file filters. |
Public Fields
There are no public fields.
Public Methods
Return Type |
Method |
Description |
---|---|---|
BBjString |
getSelectedFile() |
Returns the selected file or directory. |
BBjVector |
getSelectedFiles() |
Returns a list of the selected files or directories. |
void |
approve(BBjFileChooserApproveEvent ev!) |
Method invoked when the user hits the [OK] button. Sets the group namespace variable’s value to a BBjVector of the selected files or directories . Sets the group namespace variable + "_user_action" to “::SAVE::”, if the useSaveDialog flag is set, otherwise “::OPEN::” |
void |
cancel(BBjFileChooserCancelEvent ev!) |
Method invoked when the user presses the [Cancel] button or closes the dialog. Sets the group namespace variable’s value to null(). Sets the group namespace variable + "_user_action" to “::CANCEL::”. |
void |
closeWindow(BBjCloseEvent ev!) |
Method invoked when the user closes the dialog, thereby canceling any selection. |
Invocation
This BBj custom class may be instructed to handle events itself or not. By default, events are not handled by the class, but left to the calling process. In order to have the class handle events itself, set the value of the group namespace variable passed in the constructor to “process_events“ before instantiating the class.
The FileChooser utility class contains an example of using it at the end of the program file “FileChooser.bbj” found in the utils directory under the BBj installation. Invoke it by simply running “FileChooser.bbj”.
Also contained in the FileChooser directory is a test program showing how to invoke the FileChooser in "CUI" style. The FileChooser class is instructed to invoke process_events.
See Also