addlistener in R2014b can't access new property value?
3 ビュー (過去 30 日間)
古いコメントを表示
Is addlistener useless in 2014b? See example below. In older versions the "ev" input to the listnn function would have a field containing the new value that the property is being set to (ev.NewValue)... but in 2014b I don't see the new property value anywhere in the listnn function's inputs.... which seems to defeat the purpose of having listeners...
Is there some new method to get the new property value?
function listenertest
figure
a=axes('xtick',[0 .5 1])
addlistener(a,'XTick','PreSet',@listnn)
set(a,'xtick',[.1 .2 .3 .4]) %<-- triggers listener
function listnn(src,ev)
keyboard %<-- can't find [.1 .2 .3 .4] anywhere
1 件のコメント
Reto Zingg
2015 年 4 月 15 日
Matt, have you found a solution to the problem? I have the exact same issue. I used to listen for a change in XTick to change the labels (e.g. 1000 -> 1k). But as you mentioned, resizing or paning the plot does not fire the listener anymore...
回答 (2 件)
Doug Hull
2014 年 11 月 6 日
編集済み: Doug Hull
2014 年 11 月 6 日
So this will work, since you know the values you want int there, pass them in like any other argument to the call back.
function listenertest
figure
a=axes('xtick',[0 .5 1])
nv = [.1 .2 .3 .4];
addlistener(a,'XTick','PreSet',@(o,e)listnn(o,e,nv))
set(a,'xtick',nv) %<-- triggers listener
function listnn(src,ev,newval)
keyboard %<-- can't find [.1 .2 .3 .4] anywhere
Sean de Wolski
2014 年 11 月 6 日
編集済み: Sean de Wolski
2014 年 11 月 6 日
The NewValue event property is gone in R2014b. It is probably a release notes bug that it's not in there.
Why do you want it? It only affects the PreSet event, in the PostSet event you can query the value directly.
2 件のコメント
Sean de Wolski
2014 年 11 月 6 日
I would wrap another class around the axes or uicontrol that stores the old/new values.
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!