I am in the process of migrating a GUI I created using MATLAB's GUIDE to App Designer (2019b). In GUIDE, I added code to the main function that would wrap around any action taken using the GUI. The two pieces of functionality I added were:
- Error handling, so that I could catch any unexpected error in the entire application and print it out to an error log.
- Changing the cursor to the spin-wheel while any code was being executed, so the user knew that it was still thinking.
I included a simplified excerpt at the bottom of what I had for my main function.
My problem now is that I'm trying to recreate the same functionality in App Designer, but the constructor code is completely locked down and uneditable. Is there a way to create any sort of wrapper code that would have the same effect in App Designer? Maybe a way to overload some function?
try % Setup a try/catch around all callbacks
% Set the cursor to the spin-wheel
set(varargin{4}.figure1,'pointer','watch'); % varargin{4} = handles;
drawnow;
% Call callback function as normal
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% Set cursor back to arrow when done
set(varargin{4}.figure1,'pointer','arrow');
drawnow;
catch ME
% Catch unexpected errors, write out to log file, and reset cursor
reportErrorLog(ME,varargin{4},true);
set(varargin{4}.figure1,'pointer','arrow');
drawnow;
% Smoothly exit function with appropriate nargout
if(nargout)
varargout(1:nargout)={[]};
end
end