Create listener for changes in position of a figure window

조회 수: 9 (최근 30일)
Matt J
Matt J 2021년 5월 17일
댓글: Matt J 2021년 5월 18일
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?

채택된 답변

Jonas
Jonas 2021년 5월 17일
편집: Rik 2021년 5월 17일

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Programming에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by