How to set focus in UI figure?

5 vues (au cours des 30 derniers jours)
Jan Kudlacek
Jan Kudlacek le 5 Jan 2022
Commenté : Jan Kudlacek le 5 Jan 2022
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 commentaires
Deepu S S
Deepu S S le 5 Jan 2022
% 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 le 5 Jan 2022
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?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by