필터 지우기
필터 지우기

Listening for a property to be linked to.

조회 수: 3 (최근 30일)
Matt
Matt 2012년 7월 25일
Hi all,
Simple question - what's the best way to listen for a property of one object being linked with the property of another object?
I've been attempting to perform a given action when a property of a graphics object is changed. This is fairly simple ie. for figure visibility -
setappdata(gcf,'Visible_Listener',addlistener...
(gcf,'Visible','PostSet',@Visible_CallBack))
However, when properties are linked, it seems that changes to the property of one of the linked objects can modify the linked property of the others without triggering the listener. Is there a good way to circumvent this issue so that callbacks are triggered when a linked property is changed?

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 7월 25일
편집: Sean de Wolski 2012년 7월 25일
It's working for me:
%The example from doc linkaxes
load count.dat
figure
ax(1) = subplot(2,1,1);
bar(ax(1),count(:,1),'g');
ax(2) = subplot(2,1,2);
bar(ax(2),count(:,2),'b');
linkaxes(ax,'x');
addlistener(ax(2),'XLim','PostSet',@(src,evt)disp('hello world'));
set(ax(1),'XLim',[4.5 9.5])
  댓글 수: 3
Matt
Matt 2012년 7월 26일
Ok, so actually it doesn't break down at all. Just the callback can't assume that the object generating the callback is the current object. Simple enough fix. Thanks so much for setting me straight!
Sean de Wolski
Sean de Wolski 2012년 7월 26일
You're welcome!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by