Create listener for changes in position of a figure window

9 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Jonas
Jonas il 17 Mag 2021
Modificato: Rik il 17 Mag 2021

Più risposte (0)

Categorie

Scopri di più su Graphics Object Programming in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by