.m callback to app designer issue

1 view (last 30 days)
Ryan Sandberg
Ryan Sandberg on 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

Answers (0)

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!