Unable to get uifigure to focus programmatically

11 vues (au cours des 30 derniers jours)
Megan Rutherford
Megan Rutherford le 1 Mar 2021
I have a uifigure with a menu bar (Matlab 2020b). When I click on the menu bar, the uifigure looses focus. I have a uifigure windowKeyPress callback which requires the uifigure to be in focus to work. At the moment after selecting the menu bar, I have to click on the uifigure to make it regain focus. I would like to regain the figure focus programmatically without having to click within the uifigure. I have tried:
figure(hUIFigure)
However, this does not work.

Réponses (1)

Shadaab Siddiqie
Shadaab Siddiqie le 4 Mar 2021
Modifié(e) : Shadaab Siddiqie le 4 Mar 2021
From my understanding uifigure is loosing focus. Here is a potential work arounds:
%==== OPTION 1 ====
figure(app.UIFigure);
%==== OPTION 2 ====
app.UIFigure.Visible = 'off';
app.UIFigure.Visible = 'on';
This issue occurs because the MATLAB Window is created as a separate process.

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!

Translated by