필터 지우기
필터 지우기

Problem with uiwait and uiresume

조회 수: 2 (최근 30일)
Lukas
Lukas 2012년 9월 25일
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

답변 (1개)

Matt Fig
Matt Fig 2012년 9월 25일
편집: Matt Fig 2012년 9월 25일
You need to update the structure with the GUIDATA function.
guidata(gcbf,handles)
  댓글 수: 11
Matt Fig
Matt Fig 2012년 9월 28일
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 2012년 10월 1일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by