0

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:

  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
David K
  • 1,296
  • 18
  • 39
  • 1
    If the GUI layout is finished, all buttons etc in the right place, you can export the GUI to an m file. Then you can edit the constructor. Don't know for sure if you can then achieve what you want though. Plus it's not so convenient if you want to change the layout, then you'd have to manually edit the constructor again. – rinkert May 21 '20 at 21:36
  • @rinkert Yeah, definitely not finished with the layout yet, but I will keep that in mind if I don't find another solution. – David K May 22 '20 at 11:44

0 Answers0