Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Edit CloseRequestFcn || varargin with GUIDE GUI

Subject: Edit CloseRequestFcn || varargin with GUIDE GUI

From: Maxx Chatsko

Date: 3 Dec, 2012 16:48:13

Message: 1 of 1


I have one main GUI and one secondary GUI that is created upon pushing a button on the main. The secondary GUI has hardware drivers tied to it that don't play very nicely with MATLAB, so I would like to control when it can be closed.

I have commented out the line that closes the figure in CloseRequestFcn. Unfortunately, this tiny change dictates any attempt to close the figure in any way (command window, other functions, etc).

Is it possible to control how/when CloseRequestFcn closes its respective figure?

As a way around this I was thinking about calling the secondary GUI with an input such as:

handles.MyFun = MyFun(1); %first call

Then in the CloseRequestFcn, I could have a switch/case that will only close the figure if the input is, say, a 2.

handles.MyFun = MyFun(2); %call that ensures handles.MyFun are most recent

The only problem is that I have no idea how to declare inputs with a GUIDE generated GUI. Does anyone know how to manipulate the varargin code to pass inputs into the GUI? I know the initialization code says "DO NOT EDIT", but it is just so tempting.

function varargout = MyFun_videoFeed(varargin)
%Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
                   'gui_Singleton', gui_Singleton, ...
                   'gui_OpeningFcn', @MyFun_videoFeed_OpeningFcn, ...
                   'gui_OutputFcn', @MyFun_videoFeed_OutputFcn, ...
                   'gui_LayoutFcn', [], ...
                   'gui_Callback', []);
if nargin && ischar(varargin{1})
   gui_State.gui_Callback = str2func(varargin{1});

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
    gui_mainfcn(gui_State, varargin{:});
% End initialization code - DO NOT EDIT



Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us