Lists of Items in a Programmatic UI
setappdata(fh,'Dirty',yes_no);
% Also disable or enable the File->Save item according to yes_no
saveitem = findobj(fh,'Label','Save');
if yes_no
if isgraphics(saveitem)
saveitem.Enable = 'on';
end
else
if isgraphics(saveitem)
saveitem.Enable = 'off';
end
end
The isguidirty function queries the application data with getappdata to determine
whether the figure needs to be saved in response to closing the window.
Add an “Import from File” Option to List Master
If you want to round out List Master's capabilities, try activating the File > Import list
from file menu item. You can add this feature yourself by removing comments from
lines 106-108 (enabling a File > Import list > from file menu item) and adding your
own code to the callback. For related code that you can use as a starting point, see the
lmfileexport callback for File > Export list > to file.
Add a “Rename List” Option to List Master
When you import data to a list, you replace the entire contents of the list with the
imported text. If the content of the new list is very different, you might want to give
a new name to the list. (The list name appears above the list box). Consider adding a
menu item or context menu item, such as Rename list. The callback for this item might
perform these tasks:
- Call lm_get_list_name to get a name from the user (perhaps after modifying it to
let the caller specify the prompt string.) - Do nothing if the user cancels the dialog.
- Obtain the handle of the uipanel with tag 'lmtitlepaneltag'.
- Set the Title property of the uipanel to the string that the user specifies.
After renaming the list, the user can save the to a new FIG-file by selecting Save as. If
the UI had been saved previously, saving it to a new file preserves that version of the UI
with its original name and contents.