[co,fig] = gcbo does not work in slider listener

1 回表示 (過去 30 日間)
Norton Allen
Norton Allen 2012 年 12 月 14 日
While the figure handle is passed directly to a slider listener, I have a fairly deeply nested library function that has relied on [co,fig] = gcbo to determine the figure. I can modify the library function and all the intervening functions to allow the figure to be passed down explicitly, but is there another easier way to identify the callback figure in this case?
[co,fig] = gcbo returns:
co = schema.prop
fig = []

回答 (1 件)

Matt Fig
Matt Fig 2012 年 12 月 14 日
Use FINDALL.
fig = findall(0,'type','figure','tag','myfiguretag')
  2 件のコメント
Norton Allen
Norton Allen 2012 年 12 月 14 日
Correct me if I'm wrong, but this does not identify the figure that was involved in the current operation/callback, right? I am likely to have more than one instance open.
Matt Fig
Matt Fig 2012 年 12 月 14 日
編集済み: Matt Fig 2012 年 12 月 14 日
Yes, that is true. I guess I would need an example to suggest how you can avoid passing the figure handle. I can speculate that one way to do it would be to set a switch in the slider listener then look for that switch in the nested function.
So set all figure's userdata to 0 in the initialization code. Then in the listener,
set(gcbf,'userdata',1)
so that in the library function:
fig = findall(0,'userdata',1);
% code...
set(fig,'userdata',0) % On exit
Or something like that.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by