https://kr.mathworks.com/help/matlab/creating_guis/multiwindow-app-gui-in-app-designer.html
핵심코드
<메인 창>
1) properties (Access = Private)
properties (Access = private) DialogApp CurrentSize = 35; CurrentColormap = 'Parula'; end |
2) methods (Access = public)
function updateplot(app, sz, c) app.CurrentSize = sz; app.CurrentColormap = c; Z = peaks(sz); surf(app.UIAxes, Z); colormap(app.UIAxes, c); app.OptionsButton.Enable = "on"; end |
3) Callback Function
3-1) 앱이 시작될 때 데이터 로딩 및 초기화를 수행하는 기능
function startupFcn(app) updateplot(app, app.CurrentSize, app.CurrentColormap) end |
3-2) Options 버튼을 클릭할 때 기능하는 콜백함수
function OptionsButtonPushed(app, event) app.OptionsButton.Enable = 'off'; szvalue = app.CurrentSize; cvalue = app.CurrentColormap; app.DialogApp = DialogAppExample(app, szvalue, cvalue); end |
3-3) UI창을 닫을 때 기능하는 콜백함수
function UIFigureCloseRequest(app, event) delete(app.DialogApp) delete(app) end |
<대화상자 창>
1) properties (Access = Private)
function OKButtonPushed(app, event)
updateplot(app.CallingApp, app.SampleSizeEditField.Value, app.ColormapDropDown.Value);
delete(app)
end
updateplot(app.CallingApp, app.SampleSizeEditField.Value, app.ColormapDropDown.Value);
delete(app)
end
properties (Access = private) CallingApp end |
2) Callback Function
2-1) 앱이 시작될 때 데이터 로딩 및 초기화를 수행하는 기능
function startupFcn(app, caller, sz, c) app.CallingApp = caller; app.SampleSizeEditField.Value = sz; app.ColormapDropDown.Value = c; end |
2-2) OK 버튼을 클릭할 때 기능하는 콜백함수
function OKButtonPushed(app, event) updateplot(app.CallingApp, app.SampleSizeEditField.Value, app.ColormapDropDown.Value); delete(app) end |
2-3) UI창을 닫을 때 기능하는 콜백함수
function UIFigureCloseRequest(app, event) if isvalid(app.CallingApp) app.CallingApp.OptionsButton.Enable = 'on'; end delete(app) end |