From: "Ian Woloschin" <ian@woloschin.com>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webcrossing
Newsgroups: comp.soft-sys.matlab
Subject: Re: Interrupt for Current Figure Change
Message-ID: <ef3860a.1@webcrossing.raydaftYaTP>
Date: Thu, 1 Jun 2006 12:43:10 -0400
References: <ef3860a.-1@webcrossing.raydaftYaTP> <ef3860a.0@webcrossing.raydaftYaTP>
Lines: 61
NNTP-Posting-Host: 63.165.50.175
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:352908



I've considered trying to use the WindowButtonDownFcn, but I haven't
done any serious work on that yet. I'm actually using the
WindowButtonDownFcn already, but if I compare the figure that's
active to the one I think should be active, that would let me know if
the user made a new figure the current figure.

However, this does not take into account if they alt-tabbed into the
figure or clicked the title bar, etc, as you said. For my purposes,
the above may be enough as my program requires you to click on the
axes eventually to do anything, but it's a rather silly way to go
about writing a program.

 Perry wrote:
>
>
> Ian,
>
> I think what you need here is an 'OnFocus' function, i.e. a
> function
> that is called only when the user selcts it, i.e. the figures
> becomes
> 'the focus'. The bad part is, I'm not sure Matlab enables you to
> specify one. Sure you can 'get the current figure' with gcf, but
> you
> still need to initiate this command when the figure becomes the
> focus.
>
> The nearest thing I can find to achieve this is to specify a
> WindowButtonDownFcn callback. In this function you could set some
> applicationdata that could be read by your control figure as to
> which
> figure was last active.
>
> NOTE : This function is called when the user presses the mouse
> button
> in the figure. It does NOT get called if the user selects the title
> bar or and axis within the figure, so it's not going to work 100%
> of
> the time. As I say, Matlab (I don't think) provides an 'OnFocus'
> callback option.
>
> Perry
>
> Ian Woloschin wrote:
>>
>>
>> Is it possible to detect when the current figure has changed
>> through
>> an interrupt/callback?
>>
>> I have a gui control figure that enables features (such as
> panning)
>> in other figures, but for simplicity, only one figure is active
> at
>> any given time. At this point, you need to go to the control
>> figure
>> to specify the active figure, but I'd like for the control gui
to
>> automatically update if the current figure switches from, say,
>> figure
>> 1 to figure 2.