Revert to default interactivity in Figure/axes

4 visualizzazioni (ultimi 30 giorni)
Andrey Revyakin
Andrey Revyakin il 2 Feb 2022
Commentato: Rik il 5 Feb 2022
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!

Risposte (1)

Rik
Rik il 3 Feb 2022
(untested idea)
You could iteratively loop through the children objects of your figure, wiping all callback properties. That should reset the default behavior.
  2 Commenti
Andrey Revyakin
Andrey Revyakin il 5 Feb 2022
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 il 5 Feb 2022
I was proposing to write a function that does this. Shouldn't be very difficult. Would that suit your needs?

Accedi per commentare.

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by