Revert to default interactivity in Figure/axes

4 次查看(过去 30 天)
Hi ML gurus
I have a figure with axis which shows multiple plots, with extensive custom interactivity (I have custom-defined WindowButtonUpFcn, KeyPressFcn, DeleteFcn, WindowButtonMotionFcn, HitTest etc etc). Occasionally, I save the figure for a talk/presentation as a standalone matlab fig file. When saved as a standalone file, all the interactive callbacks like WindowButtonUpFcn are no longer functional, and I do not need that functionality anymore. However, the definitions remain, and when I try to use default matlab editing functions with the standalone plot (e.g. to change colors/thicknesses of lines, etc) I get numerous error messages, since the callbacks are no longer defined with the current variable space. I can write a scrtipt to pull out the data from the existing fig and to create a brand new one. But I wonder if would if it possible to revert all callblacks to their underfined states upon saving a figure instance?
Cheers!

回答(1 个)

Rik
Rik 2022-2-3
(untested idea)
You could iteratively loop through the children objects of your figure, wiping all callback properties. That should reset the default behavior.
  2 个评论
Andrey Revyakin
Andrey Revyakin 2022-2-5
thank you, Rik. I realize that I can remove all the properties manually. Or create a new temporary figure from scratch and save that one -- that would be faster to implement, probably, b.c. I would not then have to go back and re-define all properties again (since the figure then would be needed for further data processing). I was hoping for an option to return to default no-interactivity settings for a given figure/axes.
Rik
Rik 2022-2-5
I was proposing to write a function that does this. Shouldn't be very difficult. Would that suit your needs?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by