MATLAB Answers

Give focus to an Edit Field

31 views (last 30 days)
In the app I'm making, I need to move the cursor to a textbox when I press a button such that it is ready for input. I tried placing
uicontrol(app.DistanceEditField)
in the callback for the button but it doesn't work because I’m using App Designer (MATLAB R2017a). Is there a similar way that would work in the App Designer?

  0 Comments

Sign in to comment.

Accepted Answer

Elizabeth Reese
Elizabeth Reese on 24 Aug 2017
This functionality with "uicontrol" is currently unavailable in App Designer. I have forwarded your feedback to our developers and they will consider adding support for this in a future release of MATLAB.

  8 Comments

Show 5 older comments

Sign in to comment.

More Answers (1)

Adam Danz
Adam Danz on 20 Aug 2020
Until MathWorks supports a method of setting the current object within an app programmatically, a workaround is to use the Tab key to cycle through app components.
If the target object (the text box in this example) is listed directly under the current object (the button) within the component browser in AppDesigner, that's just 1 key stroke of the tab button.
To change the order of components, use HierarchyViewer from the file exchange (until Matlab provides a method of doing that internally within AppDesigner).

  0 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!