Invoke a callback progammatically without interrupting the current callback.
5 views (last 30 days)
Show older comments
I'm trying to call callback_A from callback_B (same GUI). Callback_A contains a simple while loop that that gets interrupted just fine if it is called by clicking its button. However when I call callback_A from inside callback_B like so,
pollBtn_callback(ud.fig.pollBtn,[])
callback_B does not exit until I kill the loop. I tried changing the 'Interruptible' property of callback_B's object to 'off' but the behavior does not change.
How can I call callback_A so that, similar to if the button is clicked, callback_B will finish then callback_A will execute?
0 Comments
Answers (1)
Walter Roberson
on 19 Oct 2016
Leave the callback set to Interruptible and Busy Action set to Queue, which are the defaults. But in callback A, you need to call one of drawnow() or pause() or uiwait() or waitfor() or figure() in order for the graphics queue to be processed to allow the push button to interrupt.
2 Comments
Walter Roberson
on 20 Oct 2016
You want a button to be able to interrupt the function of callback_A when the function is called from a callback_B that is being run because the user clicked on something for which callback_B is the callback. The callback_B -> callback_A chain is interruptable by graphics events if the graphics object that calls callback_B is set for Queue and Interruptable and callback_A is using drawnow() or pause() to give opportunities for the queue to be serviced.
See Also
Categories
Find more on MATLAB Support for MinGW-w64 C/C++ Compiler in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!