Thread Subject: Dependent gui figures

Subject: Dependent gui figures

From: jason

Date: 29 Nov, 2007 19:14:49

Message: 1 of 2

I'm working with a gui that has a few dependent figures
that it works with. I'm having some problems dealing with
those dependant figures, mainly:

1.if I give the main figure focus (not necessarily by
clicking on it, so ButtonDownFcn doesnt work) the other
figures should be given the second, third, etc. positions,
ahead of others.

2. If I move the main figure, I would like the other
figures to maintain their relative positions to the main
figure.

Ultimately I'm curious if there is a way to capture the
motion of the gui and the gaining of focus as events, and
be able to write code that executes when these events
happen.

Thanks for any help
Jason

Subject: Dependent gui figures

From: Matt Fig

Date: 29 Nov, 2007 19:53:56

Message: 2 of 2

In partial answer to your second question, here is an
attempt... you will need to work on it more.

Copy and paste the below into a new M-file and run it. It
creates 2 figures. When you move the second figure to a new
position, then click inside it, the first figure will move
to the same relative position. Not exactly what you wanted
but it should get you started. Good luck.

%--------------------------------------------------------

function [] = tracker()

h1 = figure('units','pixels','position',[400 400 200 200]);
h2 = figure('units','pixels','ButtonDownFcn',{@mvr,h1});
set(h1,'userdata',get(h2,'position'))

function [] = mvr(handles,varargin)
h1 = varargin{2};
pos1 = get(h1,'position');
pos2old = get(h1,'userdata');
pos2new = get(gcf,'position');
df = pos2new-pos2old;
set(h1,'position',pos1+df)
set(h1,'userdata',pos2new)


%--------------------------------------------------------

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

Tag Activity for This Thread
Tag Applied By Date/Time
user action jason 29 Nov, 2007 14:15:21
windowbuttondownfcn jason 29 Nov, 2007 14:15:21
windowbuttonmotionfcn jason 29 Nov, 2007 14:15:21
dependent jason 29 Nov, 2007 14:15:21
buttondownfcn jason 29 Nov, 2007 14:15:21
windowbuttonupfcn jason 29 Nov, 2007 14:15:21
gui jason 29 Nov, 2007 14:15:20
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com