How to set focus in UI figure?

6 次查看(过去 30 天)
Jan Kudlacek
Jan Kudlacek 2022-1-5
Dear colleagues
I am creating a GUI with multiple buttons. Normally, by default, pressing space bar equals clicking on the button which has the focus (usually last clicked button). In my app, space bar has, however, another function and I do not want the space bar to trigger any button. In my previous version I used figure instead of uifigure and I programatically set focus on an uicontrol of Text type in each button callback function. This way the clicked button lost focus because the focus was set on a non-clickable text and, therefore, pressing space bar did not trigger any button. The syntax for setting focus was uicontrol(uiCtr).
Now I want to use uifigure and associated uibutton and uilabel functions for creating the GUI. uilabel(uiLbl) does not work since it is trying to make a new label as a child of the uiLbl not just set focus on uiLbl.
How can I make sure that none of the buttons have focus? Is there any other way to prevent space bar from triggering the last clicked button?
  2 个评论
Deepu S S
Deepu S S 2022-1-5
% create a new uifigure h = uifigure('Name','This is my figure'); % create a new uilabel as a child of uifigure lh = uilabel(h) % create a figure to switch the focus figure; % this creates a new uifigure then switch back uifigure() uifigurepop(h); Your figure is now rendered topmost on the screen.
Jan Kudlacek
Jan Kudlacek 2022-1-5
Dear Deepu
Thank you for your response. I'm not sure you understood my question. It is not related to switching between figures. The question is how to programatically control focus on uibuttons within uifigure. Does creating one more figure help?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by