How to track second figure like the Property Inspector window?
Mostrar comentarios más antiguos
I want to make my own GUI that has a main figure window and a second that acts as the control panel, and "sticks"to the main figure much like the Property Inspector window does for a figure. I tried to create a listener for the position property change
f = figure;
l = addlistener(f, 'Position', 'PostSet', @(src,evt) disp(src))
which throws an error:
Error using matlab.ui.Figure/addlistener
While adding a PostSet listener, property 'Position' in class
'matlab.ui.Figure' is not defined to be SetObservable.
I tried this with the OuterPosition, InnerPosition, etc. with the same result.
I then tried to see what I could do with some of the callbacks available on the figure, but they seem to only work when inside the figure, not on the title bar where you would grab it to move it.
I know I could use SizeChangeFcn if it gets resized, but how can I move it to always be say 10 pixels left of the figure?
I found this thread which seems to suggest what I want is not possible: https://www.mathworks.com/matlabcentral/answers/169597-properties-of-graphic-objects-not-observable-any-more-in-r2014b
I even tried to subclass matlab.ui.Figure to change its position property to SetObservable but it is sealed.
1 comentario
Chris Dean
el 15 de Feb. de 2020
Respuestas (1)
Zachary
el 14 de Mzo. de 2023
1 voto
It is unfortunate that the Position property of the Figure class is not SetObservable.
However – at least as far back as R2016b (didn't check any further) – MathWorks defined several useful Events broadcast by the Figure class. Two of these events are LocationChanged and SizeChanged. You can listen for these events instead.
For anyone that stumbles upon this post and wants to create a MATLAB App that follows a figure window like Property Inspector, attached is a template.
With the MLAPP-file somewhere on your Search Path, this code creates a figure and attaches the "following" app.
leader = figure('Name',"Leader");
Follower(leader)
Categorías
Más información sobre Graphics Object Properties en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!