User`s guide

List Box Director y Reader (GUIDE)
is a file, it is passed to the open command; if it is a folder, the GUI changes
to that folder and lists its contents.
Define How to Open File Types. The
open comm and can handle a number
of different file types, however, the callback treats FIG-files differently.
Instead of opening the FIG-file as a standalone figure, it opens it with
guide
for editing.
Determine Which Item the User Selected. Since a single click of an item
also invokes the list box callback, you must query the figure
SelectionType
property to determine when the user has performed a double click. A
double-click of an item s ets the
SelectionType property to open.
All the items in the list box are referenced by an index from
1 to n. 1 refers
to the first item and
n is the index of the nth item. The softw are saves this
index in the list box
Value property.
The callback uses this index to get the name of the selected item from the list
of items contained in the
String property.
Determine Wheth er th e S elected Item is a File or Directory. The
load_listbox function uses the dir command to obtain a list of values that
indicate whether an item is a file or folder. These values (1 for folder, 0
for file) are saved in the
handles structure. The list box callback queries
these values to determine if current selection is a file or folder and takes
the following action:
If the sele c tion is a folder change to the folder (
cd)andcallload_listbox
again to populate the list box with the contents of the new folder.
If the selection is a file get the file extension (
fileparts) to determine
if it is a FIG-file, which is opened with
guide. All oth er file typ es a r e
passed to
open.
The
open statem ent is called within a try/catch block to capture errors in an
error dialog box (
errordlg), instead of returning to the command line.
get(handles.figure1,'SelectionType');
% If double click
if strcmp(ge t(ha ndles.figure1,'Selectio nType'),'open')
index_selected = get(handles.listbox1,'Value');
10-59