I have created a little GUI that I can launch from a given figure with a bunch of lines. This GUI allows me to grab data from the figure, manipulate them, and plot back to the figure (or another figure) by typing commands in the text box as shown below in the same way one would in the main Command Window.
I want to add the same Command History feature to this little box that is available in the main Command Window where you can hit the up arrow and brings previously typed commands. Or it can be another pushbutton and maybe a listdlg that shows all previously typed commands.
Maybe a scheme will be that every time I hit enter or semi-colon in writing the commands in the text box, it will respond and store what's currently typed in the text box? Then, if I choose "Previous Commands" option from the right-most popup menu, it will generate a listdlg and let the user to choose the commands?
I guess I can store the commands in the Tag of the editor GUI and access them. The part I don't know how is for Matlab to know when to execute storing as mentioned about (semi-colon or enter).
Currently, I'm not using GUIDE, but just a bunch of uicontrols.
How about simply saving the strings into a char array of pre-defined size and then everytime the user presses enter, store the new string in a new row of the char array. If you want to actually run the command just access that cell of the char array corresponding to the row the user is typing on?
EDIT:
As long as there is a ";" and an enter the edittext will store on separate rows of a char array so simply do this to store all data in char array:
function edittext_KeyPressFcn(hObject, eventdata, handles)
key = get(gcf,'CurrentKey');
if(strcmp(key,'return'))
commands=get(handles.edittext,'String');
lastline = commands(end,:) %gets the last written line for execution
end
end
%put this in where you want the user to click a button and display the text on listofdata textview
set(handles.listofdata,'String',commands);
Let me know if this does what you want or clarify what it is you want