Setting focus in AppDesigner

I'm setting a TextArea object to be editable with a menu selection to allow a field to be updated by the user.
The callaback to do so works fine but it is annoying to have to manually select the text area to get it to have focus and then do the edits.
Is there any way programmatically for the menu callback function to shift focus to the textarea object?
This is in an AppDesigner application.

回答 (2 件)

Adam Danz
Adam Danz 2022 年 4 月 5 日

2 投票

> Is there any way programmatically for the menu callback function to shift focus to the textarea object?
Yes, starting in MATLAB R2022a.
Use the new focus(c) function to set focus to a ui component c. This MATLAB release also provides additional resources to control the focus order of ui components in AppDesigner.
More info
Kevin Holly
Kevin Holly 2021 年 9 月 29 日

0 投票

5 件のコメント

dpb
dpb 2021 年 9 月 29 日
Which only produced an enhancment request over four years ago that still isn't available... :(
The workarounds are still klunky at best.
Tomas Ulrich
Tomas Ulrich 2022 年 1 月 2 日
What are the workarounds for this?
dpb
dpb 2022 年 1 月 3 日
The Answer at the above Q? is, so far, the best there seems to be... https://www.mathworks.com/matlabcentral/answers/353504-give-focus-to-an-edit-field#answer_482807 which is to rely on defining the uicontrol tab order and then use <TAB> to select.
Nothing at all programmatically, unless one could figure out a way to stuff/simulate keystrokes into the Windoes event queue knowing which was the present control with focus. I'd not want to even try...
Sean de Wolski
Sean de Wolski 2022 年 1 月 3 日
You may be interested in the R2022a prerelease. And while you're looking at it, you may be interested in typing >>doc focus
dpb
dpb 2022 年 1 月 3 日
That will be a boon, indeed, @Sean de Wolski.
I generally upgrade only once/year and have pretty-much stayed with a previous year b release...no real reason other than rarely need "bleeding edge", just habit.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeDevelop Apps Using App Designer についてさらに検索

製品

リリース

R2020b

質問済み:

dpb
2021 年 9 月 29 日

回答済み:

2022 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by