How can I invoke a State button without pressing it manually, but doing it programatically?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have been trying to invoke the state button callback in my program by pushing another button (push button). For example, lets say that I have provided one state button (or check box button: does not matter) and one push button. When user press the state button, some actions are taken in the program. However, I want to do this by not using the "State button" but by using the "push button", i.e. same actions are taken when "push button" is pushed.
I can trigger another "push button" using another "push button" but, when it comes to the callbacks which requires "event", I could not achieve that.
Any help is greatly appreciated.
0 commentaires
Réponses (1)
Mario Malic
le 6 Déc 2020
Hello,
To my slim knowledge, I wouldn't recommend it to run another callback within one. It could be better if you would wrap the code from the state button callback into a function that you'd call within other callbacks.
Current state
function CallbackFcn1(src, event)
%some code
end
function CallbackFcn2(src, event)
%some code as well
end
Wrap your code like this
function HelperFcn()
%some code
end
function CallbackFcn1(src, event)
HelperFcn()
end
function CallbackFcn2(src, event)
%some code as well
HelperFcn()
Make sure you change state value to true either within HelperFcn
or in body of this function
end
2 commentaires
Mario Malic
le 6 Déc 2020
I am saying that that complicated code within a callback, put it in a function, and call it that way. You replace the body of the callback with a single line which calls the function.
Voir également
Catégories
En savoir plus sur Model, Block, and Port Callbacks dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!