fixfocus

버전 1.2 (545 KB) 작성자: Jorg Woehl
MATLAB function to fix an annoying, long-standing focus bug with selection dialog boxes and uifigure windows
다운로드 수: 17
업데이트 날짜: 2024/5/15

View fixfocus on File Exchange

fixfocus

fixfocus provides a workaround for an annoying, long-standing MATLAB user interface bug that occurs when a selection dialog box is opened in presence of an app/uifigure window that has focus.

Background

Since at least R2016b, MATLAB does not move the selection dialog box into focus when an app or uifigure window is present and has focus. Instead, the selection dialog box appears behind the app or uifigure window:

uigetfile

fixfocus provides a workaround that automatically brings the selection dialog box into focus.

When the the selection dialog box is closed by the user, fixfocus then returns the focus to the app/uifigure window -- thus fixing a second user interface bug that persists to this day in MATLAB.

Usage

Sandwich the call to the selection dialog box (e.g., a call to uigetfile) between the following two lines:

ff = fixfocus;
% 'uigetfile', 'uitputfile', 'uigetdir', 'uiopen', or 'uisave' command
delete(ff);

This works with uigetfile, uitputfile, uigetdir, uiopen, and uisave calls.

How It Works

Internally, fixfocus creates a temporary dummy figure that takes the focus away from the app/uifigure window. This allows the selection dialog box to move into focus when called.

To be as unobtrusive as possible, the dummy figure consists of just the title bar (zero height), perfectly superimposed on top of the title bar of the app/uifigure window:

fixfocus figure

This "title bar figure" only appears briefly.

As an option, fixfocus can be called with a text argument (such as 'Just a second...'). This text is then displayed in the title bar instead of the app/uifigure title, which is the default.

Note

Other potential workarounds, such as moving the dummy figure off the screen, making it invisible from the start, shrinking it to zero width and height, etc., are unfortunately not working as expected. Also, there is currently no official workaround from The MathWorks regarding these bugs.

Important

Unlike uifigure windows, figure windows do not adjust to dark mode. Therefore, the temporary dummy figure is much more noticeable in dark mode. (The title bar color of a figure cannot be set in MATLAB.)

Acknowledgments

fixfocus was inspired by this discussion in the MATLAB Answers forum.

인용 양식

Jorg Woehl (2024). fixfocus (https://github.com/JorgWoehl/fixfocus/releases/tag/v1.2), GitHub. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2024a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.2

See release notes for this release on GitHub: https://github.com/JorgWoehl/fixfocus/releases/tag/v1.2

1.0.1

See release notes for this release on GitHub: https://github.com/JorgWoehl/fixfocus/releases/tag/v1.0.1

1.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.