How can I invoke a State button without pressing it manually, but doing it programatically?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Mario Malic
el 6 de Dic. de 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 comentarios
Mario Malic
el 6 de Dic. de 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.
Ver también
Categorías
Más información sobre Model, Block, and Port Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!