From: Matthew C on
"us " <us(a)neurol.unizh.ch> wrote in message <hot26p$4tf$1(a)fred.mathworks.com>...
> "Matthew C" <twisted_mc(a)hotmail.com> wrote in message <hot1k4$o5e$1(a)fred.mathworks.com>...
> > "us " <us(a)neurol.unizh.ch> wrote in message <hosvk9$i9c$1(a)fred.mathworks.com>...
> > > "Matthew C"
> > > > Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.
> > >
> > > well... that seems a bit ...twisted...
> > >
> > > a hint:
> > > - set these fig callbacks
> > > CLOSEREQUESTFCN
> > > DELETEFCN
> > > to prevent a user from being able to close/delete a fig...
> > > - don't forget to reset them when your gui closes...
> > >
> > > us
> >
> > How do you set those call backs for a figure that is created using figure(1);?
> >
> > Thanks.
>
> a hint:
> - put the exemplary code as shown in the last reply into the figure's
> CREATEFCN callback...
>
> us

Thanks, but I am just using the Figure command to create the figure. How do I access the CREATEFCN callback?
From: us on
"Matthew C" <twisted_mc(a)hotmail.com> wrote in message <hot2v4$i7r$1(a)fred.mathworks.com>...
> "us " <us(a)neurol.unizh.ch> wrote in message <hot26p$4tf$1(a)fred.mathworks.com>...
> > "Matthew C" <twisted_mc(a)hotmail.com> wrote in message <hot1k4$o5e$1(a)fred.mathworks.com>...
> > > "us " <us(a)neurol.unizh.ch> wrote in message <hosvk9$i9c$1(a)fred.mathworks.com>...
> > > > "Matthew C"
> > > > > Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.
> > > >
> > > > well... that seems a bit ...twisted...
> > > >
> > > > a hint:
> > > > - set these fig callbacks
> > > > CLOSEREQUESTFCN
> > > > DELETEFCN
> > > > to prevent a user from being able to close/delete a fig...
> > > > - don't forget to reset them when your gui closes...
> > > >
> > > > us
> > >
> > > How do you set those call backs for a figure that is created using figure(1);?
> > >
> > > Thanks.
> >
> > a hint:
> > - put the exemplary code as shown in the last reply into the figure's
> > CREATEFCN callback...
> >
> > us
>
> Thanks, but I am just using the Figure command to create the figure. How do I access the CREATEFCN callback?

one of the solutions

fdr=@(varargin) 'disp(''DELETE'');';
fcr=@(varargin) 'disp(''CLOSE'');';
fcf=@(varargin) set(gcbo,...
'closerequestfcn',fcr(),...
'deletefcn',fdr(),...
'handlevisibility','off'); % <- was wrong in the last example(!)...
fh=figure('createfcn',fcf);

us
From: matt dash on
"Matthew C" <twisted_mc(a)hotmail.com> wrote in message <hosuto$6cu$1(a)fred.mathworks.com>...
> So I have a GUI. You press a button and it runs a for loop, each iteration of the for loop does a calculation and plots something to "Figure 1". In fact, it plots 2 subplots on Figure 1, each subplot contains a number of data sets.
>
> My problem is when the user "closes" the figure in the middle of plots, MATLAB defaults to plotting over the GUI. I have tried different combinations of:
>
> - getting figure handle h = figure(1);
> - set(0, 'currentfigure', h) before EACH plot
> - immediately after plotting the first one, I get current axis (gca) and all plot commands from therein go to that axis
> etc.
>
> Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.
>
> Thanks.


have you tried just setting the handle visibility of your gui figure to "off" while you're plotting? I think that will prevent it from becoming the active figure.
From: us on
On Mar 30, 5:15 pm, "matt dash" <n...(a)mail.com> wrote:
> "Matthew C" <twisted...(a)hotmail.com> wrote in message <hosuto$6c...(a)fred.mathworks.com>...
> > So I have a GUI.  You press a button and it runs a for loop, each iteration of the for loop does a calculation and plots something to "Figure 1"..  In fact, it plots 2 subplots on Figure 1, each subplot contains a number of data sets.
>
> > My problem is when the user "closes" the figure in the middle of plots, MATLAB defaults to plotting over the GUI.  I have tried different combinations of:
>
> > - getting figure handle h = figure(1);
> > - set(0, 'currentfigure', h) before EACH plot
> > - immediately after plotting the first one, I get current axis (gca) and all plot commands from therein go to that axis
> > etc.
>
> > Nothing seems to work... I want the plot to plot to figure 1 REGARDLESS of if that figure exists or not.
>
> > Thanks.
>
> have you tried just setting the handle visibility of your gui figure to "off" while you're plotting? I think that will prevent it from becoming the active figure.

matt, it's part of what he/she has to do (see my reply re CLOSE ALL) -
but other attempts to close the fig will still work...
hence, the various additional reassignments of the callback
functions...

urs