Azzera filtri
Azzera filtri

Problem with uiwait and uiresume

2 visualizzazioni (ultimi 30 giorni)
Lukas
Lukas il 25 Set 2012
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

Risposte (1)

Matt Fig
Matt Fig il 25 Set 2012
Modificato: Matt Fig il 25 Set 2012
You need to update the structure with the GUIDATA function.
guidata(gcbf,handles)
  11 Commenti
Matt Fig
Matt Fig il 28 Set 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?
Lukas
Lukas il 1 Ott 2012
I hadn't set the windowstyle to modal. I did that, but it still doesn't work. The code you posted above does in fact work for me as well. As it stands I did get my original program to work, so that's good enough for now. As a theoretical exercise however it's still of interest to me as to why my original method didn't work.
Thanks for all your help,
Lukas

Accedi per commentare.

Categorie

Scopri di più su Migrate GUIDE Apps in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by