MATLAB: What does it mean when a UICONTROL is in “focus” in MATLAB

activecallbackcurrentdocumentationfocusMATLABpushbuttonspacebaruicontrol

I would like to know what the term "in focus" means for UICONTROL objects in MATLAB.

Best Answer

A UICONTROL such as a pushbutton is in focus when it is the last UICONTROL with which a user interacted or when the tab key is used to choose that UICONTROL. For a pushbutton, the dotted line around the pushbutton indicates that it is in focus.
Pressing the spacebar triggers the callback of the UICONTROL which is in focus. Note that a UICONTROL only becomes the current object when its callback is called. Clicking on pushbuttons, checkboxes, radiobuttons, sliders, listboxes and togglebuttons calls their callback, and sets them to be the current object. Edit controls, however, operate differently - they do not call their callback until they lose focus, or until you hit Enter.
For example, you can run your GUI and initially click on a UICONTROL to give it focus. When you press the Tab key, you can expect the GUI to tab through the other UICONTROLS.
Note that there is a bug in MATLAB 6.5 (R13) which does not display which UICONTROL receives focus. For more information, refer to the following solution:
For information on how to give focus to a particular UICONTROL, refer to the following solution: