How to set focus in UI figure?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
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.
Réponses (0)
Voir également
Catégories
En savoir plus sur Develop uifigure-Based Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!