Uninterruptible GUI Callback without User Input
显示 更早的评论
I made a GUI with GUIDE which, when a button is pressed, triggers an interruptible callback (named C1) that runs a while loop until an exit condition is met. In the while loop, there is a section of code that once started must run to completion without interruption. If the callback is interrupted while executing this code, the interrupting callback must be executed after the code has finished.
I've tried using the waitfor function but it doesn't work as needed in the case of callbacks. I've also tried making an uninterruptible callback (named C2) run the important code and calling that C2 from within the while loop of C1, but it seems C2 is still interruptible unless triggered by a click event on its button from the user.
Is there a way to make a function or section of code uninterruptible and triggered by code as opposed to user input?
回答(1 个)
Walter Roberson
2018-2-7
0 个投票
You can set the uicontrol Interruptible property to 'off' and 'BusyAction' to 'queue'
Or, you can set all buttons to 'Enable', 'disable' while running the critical routine.
Instead of having to know about all other buttons to change their Enable properties, you can also put the critical button inside a figure whose 'WindowStyle' is set to 'modal' (and set that one object to Interruptible off or set that one button Enable 'disable' during the critical action.)
1 个评论
Biraj Khanal
2022-1-19
I tried and saw that Interruptible and Busyaction do help when you use buttons.
The uicontrol do not help when it comes to something like a cellEdit of a table. While editing a cell, if you triger another function like cellselection of another table, it simply switches the flow to the trigerred function without completing the celledit first.
Do you have any suggestion?
Not sure if this is legal here but I here is a link to the detail of my question.
https://de.mathworks.com/matlabcentral/answers/1630540-complete-executing-celledit-before-any-other-function-is-trigerred
类别
在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!