Problem with uiwait and uiresume
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to pass a structure from a one window to another in my GUI. To start, in the opening function, I pause the ui, using uiwait(handles.LoadWindow) (LoadWindow is the name of the child window) in order to wait for the user to input some data.
After the user does this and presses the OK button I create the structure "File" and add some fields as follows:
function OKButton_Callback(hObject, eventdata, handles)
File.Machine = get(handles.popupmenu1, 'Value');
File.Test = 'Test';
handles.output = File;
close(handles.LoadWindow);
I've added the structure to handles.output which should be returned to the main window. The child window (LoadWindow) is then closed.
At this point my understanding is that the outputFunction is automatically called:
function varargout = LoadWindow_OutputFcn(hObject, eventdata, handles)
uiresume(handles.LoadWindow)
varargout{1} = handles.output;
When I run the GUI, I get the error:
??? Attempt to reference field of non-structure array.
Error in ==> LoadWindow>LoadWindow_OutputFcn at 74
uiresume(handles.LoadWindow);
When I enter debug mode at this step my handles value is [ ]. Going back farther my handles object is fine when I press the OK button and it contains all the expected fields. It's at line 211 of gui_mainfcn.m where my handles object gets assigned the value [ ].
When I remove the uiwait/uiresume functions the code works, but it doesn't wait for the user to enter data before returning control to the main window.
I'm using Matlab r2006b on Windows 7.
Any help would be greatly appreciated.
Thanks,
Lukas
0 commentaires
Réponses (1)
Matt Fig
le 25 Sep 2012
Modifié(e) : Matt Fig
le 25 Sep 2012
You need to update the structure with the GUIDATA function.
guidata(gcbf,handles)
11 commentaires
Matt Fig
le 28 Sep 2012
So if you use code just like the above, does it work? Like I said, it works here.... Did you remember to set the windowstyle to modal in the Property inspector?
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!