.m callback to app designer issue

2 visualizzazioni (ultimi 30 giorni)
Ryan Sandberg
Ryan Sandberg il 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

Risposte (0)

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by