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

3 Ansichten (letzte 30 Tage)
David K
David K am 21 Mai 2020
Kommentiert: Mohammad Sami am 22 Mai 2020
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 Kommentare
David K
David K am 21 Mai 2020
I guess I don't feel knowledgable enough to create one from scratch, and App Designer makes it very easy to adjust the visual layout without having to worry about fixing all the relevant code.
Can you just copy/paste all of the code to a new file and retain all of the functionality, or is there hidden functionality in the .mlapp file?
Mohammad Sami
Mohammad Sami am 22 Mai 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.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by