This document describes jfs.tcl version 4.1/4.2.
The file selection panel has a number of predefined buttons, and you can choose which ones appear using the -buttons option. The first button in buttonlist will be the default button, and pressing Return in the entry widget or doubleclicking in the listbox will do the same thing as clicking on this button (unless the current file name is a directory, in which case it will switch to that directory). If the -buttons option is not specified, the ok, cancel, and home buttons will be displayed (and ok will be the default button).
The available buttons and their functions are:
ok - Return the current filename if it is a file; cd to it if it's a directory. This is the typical way to select a filename
gointo - cd to the current filename, if it's a directory. This is useful when here is the default button.
home - cd to the user's home directory.
root - cd to the root directory.
here - Return the name of the current working directory. This can be used, for instance, to choose where to move a file to.
cancel - Return cancelvalue.
If -types and -typevariable are specified, an option button, labelled typeprompt, will be displayed that lets the user choose among the file types in typelist. The j:fs procedure will set the variable typevar in the caller's scope to the element of typelist that the user selected. This is intended to let the user select a file format for saving, although it could conceivably be put to other uses.
Unless the global variable J_PREFS(j_fs_fast) is true, directory names in the listbox will have a trailing slash (/). The user can set this with a small checkbox at the upperright of the fileselection panel (as well as from the Global Preferences panel created by j:global_pref_panel, in jprefpanel.tcl).
Keyboard shortcuts for the Cancel button are set up using j:cancel_button in jtkutils.tcl, even if it doesn't appear in buttonlist. This means that the user can always cancel (returning cancelvalue) by typing (e.g.) Control-c, even if you didn't include cancel in buttonlist.
Note that while j:fs may change the working directory while it's active (i.e., when the user goes into a directory, j:fs cds into that directory to display its contents), it restores the original working directory before it returns. Since j:fs is modal, this means that you don't have to worry about your application changing directory unless you explicitly do a cd yourself. (This behaviour is different from that of previous versions.)
Any directory names will be followed by slashes (`/'), unless the global variable J_PREFS(j_fs_fast) is true.
This procedure is for use by j:fs. You may find it useful for other applications, but don't rely on it too much.
* It's nonorthogonal that j:fs returns the filename as the procedure's return value, but returns the file type in a variable as a sideeffect. I can't think of a better way to do it, though, since I want the common case (not specifying a list of file types) to be as terse and intuitive as possible.
* There should be a way to let the user select a file format.
Also, it might be nice to let the user preview a file before
selecting it.