Create listener for changes in position of a figure window
24 views (last 30 days)
Show older comments
I have been trying to use addlistener() to make it so that when one figure window is moved, another figure window shifts position by the same amount, so that their relative positions are always the same:
h1=figure(1);
plot(1:5);
h2=figure(2);
imshow(imread('cameraman.tif'));
addlistener(h2,'Position','PostSet', @(s,e)callback(s,e,h1))
function callback(h2,~,h1)
h1.Position(1:2)=h2.Position(1:2)-[500,0];
end
However, this results in,
Error using matlab.ui.Figure/addlistener
While adding a PostSet listener, property 'Position' in class 'matlab.ui.Figure' is not defined to be
SetObservable.
Error in test (line 8)
addlistener(h2,'Position','PostSet', @(s,e)callback(s,e,h1))
Does anyone know of a workaround that will allow me to do this?
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Graphics Object Programming in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!