Any way to make a global wrapper code for all callbacks in App Designer?

3 views (last 30 days)
I am in the process of migrating a GUI I created using 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:
1. Error handling, so that I could catch any unexpected error in the entire application and print it out to an error log.
2. 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
  3 Comments
Mohammad Sami
Mohammad Sami on 22 May 2020
If you are not going to compile as a webapp, you can create the GUI in AppDesigner then export the app as code.
Thereafter you will be able to edit the exported code.

Sign in to comment.

Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!