MATLAB Creating Graphical User Interfaces

(Barry) #1
Interrupt Callback Execution


  • Callback interruption — Click Wait (interruptible) immediately followed by either
    button in the second window: Surf Plot (queue) or Mesh Plot (cancel). The wait
    bar displays, but is momentarily interrupted by the plotting operation.

  • Callback queueing — Click Wait (uninterruptible) immediately followed by Surf
    Plot (queue). The wait bar runs to completion. Then the surface plot displays.

  • Callback cancellation — Click Wait (uninterruptible) immediately followed by
    Mesh Plot (cancel). The wait bar runs to completion. No plot displays because
    MATLAB discards the mesh plot callback.


Examine the Source Code


The Interruptible and BusyAction properties are passed as input arguments to the
uicontrol function when each button is created.


Here is the command that creates the Wait (interruptible) push button. Notice that the
Interruptible property is set to 'on'.


h_interrupt = uicontrol(h_panel1,'Style','pushbutton',...
'Position',[30,110,120,30],...
'String','Wait (interruptible)',...
'TooltipString','Interruptible = on',...
'Interruptible','on',...
'Callback',@wait_interruptible);


Here is the command that creates the Wait (uninterruptible) push button. Notice that
the Interruptible property is set to 'off'.


h_nointerrupt = uicontrol(h_panel1,'Style','pushbutton',...
'Position',[30,40,120,30],...
'String','Wait (uninterruptible)',...
'TooltipString','Interruptible = off',...
'Interruptible','off',...
'Callback',@wait_uninterruptible);


Here is the command that creates the Surf Plot (queue) push button. Notice that the
BusyAction property is set to 'queue'.


hsurf_queue = uicontrol(h_panel2,'Style','pushbutton',...
'Position',[30,200,110,30],...
'String','Surf Plot (queue)',...
'BusyAction','queue',...
'TooltipString','BusyAction = queue',...
'Callback',@surf_queue);

Free download pdf