Unable to get uifigure to focus programmatically

조회 수: 3 (최근 30일)
Megan Rutherford
Megan Rutherford 2021년 3월 1일
편집: Shadaab Siddiqie 2021년 3월 4일
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.

답변 (1개)

Shadaab Siddiqie
Shadaab Siddiqie 2021년 3월 4일
편집: Shadaab Siddiqie 2021년 3월 4일
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.

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by