Passing data from custom modal dialog box to main GUI

조회 수: 3 (최근 30일)
Joel Marchand
Joel Marchand 2012년 2월 6일
I am trying to pass data from a modal dialog box to a main GUI. When I run the code at 'full speed' as interpreted code, the main GUI tells me that a specific variable (handles.cancelPT) is not defined (assigned to the main GUI handles structure by the modal dialog box). When I run in debug mode (step by step) no error occurs.
Relevant main GUI code:
function performanceandthicknessmenu_Callback(hObject, eventdata, handles)
% Call dialog box for entering data to process; Wait for dialog box to close.
modelbyperformanceandthicknessdialog; uiwait(gcf);
if handles.cancelPT == true
msgbox('Operation cancelled')
elseif handles.cancelPT == false
% Executes when there is some data to calculate when optimizing by
% performance and thickness
handles.frequencyGHz
handles.loss
handles.minimumThicknessInches
handles.maximumThicknessInches
handles.angleOfIncidenceDegrees
handles.polarization
handles.absorptionMode
end
guidata(hObject, handles);
Relevant modal dialog box code:
function cancelpushbutton_Callback(hObject, eventdata, handles)
handles.cancelPT = true; % Canceled
close(gcf);
% Pass handles data on to engineering part chooser
guidata(findobj('tag', 'engineeringpartchooser'), handles);
Any pointers would be appreciated.
  댓글 수: 1
Jan
Jan 2012년 2월 6일
Please format the code as explained in the "Markup help" link.

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

채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 6일
You should not be counting on gcf to refer to the correct object.
In the cancel routine, instead of
close(gcf)
use
close(ancestor(hObject,'figure'))
Your modal dialog modelbyperformanceandthicknessdialog should not allow the calling routine to resume until the dialog is closed. The modal routine itself should do the uiwait(), not your calling code.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 App Building에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by