.
MATLAB R2022a provides app developers more control over user navigation through app components using the keyboard's Tab key.
Part 1. The new focus function: programmatically set keyboard focus to a UI component
Part 2. Modify focus order of components
Today we'll review Part 1. Come back tomorrow for Part 2.
-------------------------------------------------------------------------------------------------
Programmatically set UI component focus
Did you know that you can save ~2 seconds every time you use a keyboard shortcut rather than reaching for your mouse [1,2]?
I need you to focus here: starting in MATLAB R2022a, use the new focus function to set keyboard focus to a specific UI component.
By specifying the component handle ( c ) in focus(c),
- The figure containing the component is displayed
- A blue frame appears around the component
- The user can directly interact with the component.
.
Which components are focusable?
Focusable components are those that a user can interact with using the keyboard. So an object set to Enable='off' or Visible='off' cannot be in focus. See the documentation for more details.
What will you do with all of that extra time saved?
-------------------------------------------------------------------------------------------------
Stay tuned
Tomorrow we'll learn how to apply the new focus function with control of tab order to create contextual flow of UI component focus. Follow Community Highlights to get notifications.
Let us know what interests you in the new MATLAB R2022a release in the comment section below.
See also
- Release notes: focus
- R2021a Highlight: keyboard shortcuts for UI Components
- Download the latest release of MATLAB
Footnotes
[1] Lane et. al. (2005). International Journal of Human-Computer Interaction, 18(2).
[2] Michels (2018). median.com
This Community Highlight is attached as a live script.
2 Comments
I like that you provided citations for the time saved by using keyboard shortcuts. I have long known that they saved time, but now I know how much!
Finally!