.m callback to app designer issue

3 Ansichten (letzte 30 Tage)
Ryan Sandberg
Ryan Sandberg am 27 Nov. 2018
When I call a .m file from the app designer, in this case a listener handle the callback from the .m file to the app instantiates the startupFcn and makes a new figure. Is there a way to avoid or suppress this? I can get around this by deleting the new figure, but now the app has a "flashing" feel every time the file under watch is updated
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
global mylistener;
global file;
getcaller=dbstack();
mycaller=getcaller(5).name;
switch mycaller
case {'eventhandlerChanged'}
temp=findall(0,'Type','figure');
delete(temp(2));
case {'AppManagementService.runAppWithTryCatch'}
filepath='C:\test';
file=System.IO.FileSystemWatcher(filepath);
file.Filter='November2018.txt';
file.EnableRaisingEvents=true;
mylistener=addlistener(file,'Changed',@eventhandlerChanged);
app.Label2.Text='NOT UPDATED';
app.Label.Text='';
app.Label3.Text='';
end
end
function eventhandlerChanged(~,h1)
MainFunction(app1,h1);
end

Antworten (0)

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by