How can I add 'delete' button to listdlg?
7 views (last 30 days)
Hello all! Well I have such code
[s,v] = listdlg('PromptString','Select a file:',...
That gives me a figure where are only 'ok' and 'cancel' buttons as default, but now I want to have delete button with which I will be able delete selected variable from s structure. Any ideas would be a great job for me, Thanks in advance.
Stephen23 on 16 Feb 2015
Edited: Stephen23 on 16 Feb 2015
The standard listdlg does not support adding other buttons (or features), but one of the neat things about MATLAB is you can often adapt MATLAB's own code for your own purposes: you could rewrite the listdlg function to include another button, and make it do whatever you want it to do. Start by opening listdlg:
and then save a copy in your working directory, changing both the function and file names.
Then search for bushbutton: you will find three instances of uicontrol that are used to define the two standard and open optional button: you can easily change the code to add new buttons and features. You will need to read about uicontrol and understand how callback functions work. You will need to consider how to keep track of the cell of strings listString and change this using the delete button, and also how to refresh the listbox uicontrol when this happens.