Creating Graphical User Interfaces |
Controlling Interruptibility
All graphics objects have an Interruptible
property that determines whether their callbacks can be interrupted. The default value is on
, which means that callbacks can be interrupted. However, MATLAB checks the event queue only when it encounters certain commands - drawnow
, figure
, getframe
, pause
, and, waitfor
. Otherwise, the callback continues to completion.
The Event Queue
MATLAB commands that perform calculations or assign values to properties execute as they are encountered in the callback. However, commands or actions that affect the state of the figure window generate events that are placed in a queue. Events are caused by any command that causes the figure to be redrawn or any user action, such as a button click or cursor movement, for which there is a callback routine defined.
MATLAB processes the event queue only when the callback finishes execution or when the callback contains the following commands:
When MATLAB encounters one of these commands in a callback, it suspends execution and processes the events in the event queue. The way MATLAB handles an event depends on the event type and the setting of the callback object's Interruptible
property:
Interruptible
property is on
.
Interruptible
property.
Note that callbacks defined for an object's DeleteFcn
or CreateFcn
or a figure's CloseRequestFcn
or ResizeFcn
interrupt an executing callback regardless of the value of the object's Interruptible
property.
What Happens to Events That Are Blocked - BusyAction Property
All objects have a BusyAction
property that determines what happens to their events when processed during noninterruptible callback routine execution.
BusyAction
has two possible values:
queue
- Keep the event in the event queue and process it after the noninterruptible callback finishes.
cancel
- Discard the event and remove it from the event queue.
Interrupting Executing Callbacks | Event Processing During Callback Execution |