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:
plot steals focus

Subject: plot steals focus

From: redrothko

Date: 15 Apr, 2009 14:00:18

Message: 1 of 6

I have two figures f1 and f2. (Actually they are GUIs.) How do I plot to f1 without stealing focus from f2?

I tried the following to revert focus, but they do not work.

set(0,'CurrentFigure',handles.figure1)
openfig('f2gui.fig','reuse')

Subject: plot steals focus

From: Jonathan

Date: 15 Apr, 2009 16:01:06

Message: 2 of 6

"redrothko " <redrothko@yahoo.com> wrote in message <gs4p9i$aqd$1@fred.mathworks.com>...
> I have two figures f1 and f2. (Actually they are GUIs.) How do I plot to f1 without stealing focus from f2?
>
> I tried the following to revert focus, but they do not work.
>
> set(0,'CurrentFigure',handles.figure1)
> openfig('f2gui.fig','reuse')

When you plot, try specifying the parent axes. This should keep the focus on the current item:

plot(x,y,'parent',handles.ax1)

-Jonathan

Subject: plot steals focus

From: redrothko

Date: 15 Apr, 2009 16:40:18

Message: 3 of 6

> plot(x,y,'parent',handles.ax1)

That is a given, and I am already doing that. The problem is that figure1 becomes the focus, although the focus should remain on figure2.

At this point I am using uistack(figure2,'top') combined with pause(.5), to repeatedly bring figure2 back to focus. But this has bad side effects. It resets the properties of axes1 for some reason. Not to mention, it is annoying that the two figures keep on flashing as focus changes between them.

Subject: plot steals focus

From: redrothko

Date: 16 Apr, 2009 07:13:04

Message: 4 of 6

Setting a modal window style prevents focus from being stolen:
set(figure2,'WindowStyle','modal').

But I am still perplexed by the odd plotting behavior (e.g. the properties of figure1's axes get reset). These things do not happen when I let the focus-stealing behavior run its course.

Subject: plot steals focus

From: Steven Lord

Date: 16 Apr, 2009 14:16:39

Message: 5 of 6


"redrothko " <redrothko@yahoo.com> wrote in message
news:gs52li$3ps$1@fred.mathworks.com...
>> plot(x,y,'parent',handles.ax1)
>
> That is a given, and I am already doing that. The problem is that figure1
> becomes the focus, although the focus should remain on figure2.
>
> At this point I am using uistack(figure2,'top') combined with pause(.5),
> to repeatedly bring figure2 back to focus. But this has bad side effects.
> It resets the properties of axes1 for some reason. Not to mention, it is
> annoying that the two figures keep on flashing as focus changes between
> them.

Try using LINE instead of PLOT.

--
Steve Lord
slord@mathworks.com

Subject: plot steals focus

From: Steven Lord

Date: 16 Apr, 2009 14:17:35

Message: 6 of 6


"redrothko " <redrothko@yahoo.com> wrote in message
news:gs6lq0$jhe$1@fred.mathworks.com...
> Setting a modal window style prevents focus from being stolen:
> set(figure2,'WindowStyle','modal').
>
> But I am still perplexed by the odd plotting behavior (e.g. the properties
> of figure1's axes get reset). These things do not happen when I let the
> focus-stealing behavior run its course.

That's expected behavior when you use PLOT and HOLD is not on.

http://www.mathworks.com/support/solutions/data/1-1B5UM.html?solution=1-1B5UM

http://www.mathworks.com/support/solutions/data/1-168SX.html?solution=1-168SX

--
Steve Lord
slord@mathworks.com

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