fixfocus

版本 1.2 (544.8 KB) 作者: Jorg Woehl
MATLAB function to fix an annoying, long-standing focus bug with selection dialog boxes and uifigure windows
36.0 次下载
更新时间 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 仓库