MATLAB: Moving between different GUI’s (bypassing any intermediate GUI)

getappdataguidehandling dataMATLABmultiple guisetappdata

Hello everyone,
I am trying to send data (i.e. user input inside text field) between two different GUI's, bypassing any intermediate GUI. I created a simple GUI to accomplish this after reading multiple forums and reading the Matlab documentation, but I am still having problems. The GUI I created using GUIDE, has a static text box in the "main" GUI. Then you press a push button to move to an "intermediate" GUI that opens a "third" GUI. Finally, the last GUI has a input text box that would change the value of the static text in the "main" GUI.
From everything I read, I believe the best way to accomplish this is by using setappdata and getappdata.
I am using the following code in the opening function:
% Set waiting flag in appdata
setappdata(handles.figure1,'waiting',1)
% UIWAIT makes GUI wait for user response (see UIRESUME)
uiwait(handles.figure1);
and I am using something like the following to move to the next GUI2:
GUI2('GUI2', handles.figure1);
to move back to previous GUI I use in the close request function:
uiresume(hObject);
%I want to change this line so it goes back to main not the previous GUI
How can I move to the main GUI from the third GUI, skipping the intermediate GUI?
Thank you in advance for any help provided.

Best Answer

I believe I found a way to accomplish what I was trying to do... After calling the third GUI, I added an If statement to check if data was added to the root. If something was added to the root (data was recorded to be used in the main GUI), then immediately resume back to the main GUI. It looks something like:
Call third GUI:
testGUI3('testGUI3', handles.figure1);
if isappdata(0,'ReturnTestText')
check = getfield(getappdata(0,'ReturnTestText'), 'testText')
uiresume(handles.figure1);
end
The third GUI has two options. Record data (from the input text box) once a button is pushed (i.e. OK) or do nothing (i.e. CANCEL button).
%OK button
layers.testText = get(handles.test_edit1,'String');
setappdata(0,'ReturnTestText',layers);
uiresume(handles.figure1);
%CANCEL button
uiresume(handles.figure1);
This seems to be working. Any suggestions or comments are welcome.
Thank you for the help Evan. It is good to know different ways to accomplish a task.