how to have a callback function terminate another callback function in a GUIDE gui
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Joseph Kutteh
am 25 Mai 2021
Bearbeitet: Adam Danz
am 25 Mai 2021
i am wondering that when i click a button in a gui how can that button terminate what is going on in another callback function?
thank you
matlab version: R2019b
0 Kommentare
Akzeptierte Antwort
Adam Danz
am 25 Mai 2021
Bearbeitet: Adam Danz
am 25 Mai 2021
For this explanation, callbackFcn1 is the initial callback function and callbackFcn2 is the one that should terminate the first one.
Create a binary flag in your GUI with a default value of false. callbackFcn1 will run as long as the flag is false and there should be lots of checks within callbackFcn1 to determine if the flag is still false. If the flag ever becomes true then two things should happen. 1) use return to exit the callback functions and 2) reset the flag to false.
callbackFcn2 merely sets the flag to true which tells callbackFcn1 to stop at the next check.
Notice that you can only stop callbackFcn1 at check-points to put them in strategic places including within loops.
This answer demonstrates this process in AppDesigner but the same logic is true for GUIDE GUIs.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!