Preventing focus theft while running matlab from the command line and creating figures
3 次查看(过去 30 天)
显示 更早的评论
There have been several posts on this subject such as this thread , and proposed solutions such as the program sfigure, but nothing works for me. I'm running R2016b from linux, and opening matlab with the flags
-nosplash -nodesktop
When I run the following code, using @Walter Roberson's fix proposed in the first link
close all;
figure(1);
set(0,'CurrentFigure',1);
plot(1:10);
or using the program `sfigure` suggested in the second link
close all;
sfigure(1);
plot(1:10);
the focus thief remains as active as ever. I would so love to put this thief away for life.
Thanks for any suggestions
0 个评论
回答(1 个)
Walter Roberson
2016-12-27
Creating a figure always gives it focus. The discussion in the other thread is about how to reduce the other circumstances under which the focus might get stolen.
If you set the new figure Visible off and drawnow() almost immediately after you create the figure then you reduce the time during which the focus is at risk. The focus will mostly go back to where it was when you make the new figure visible off, but not necessarily completely reliably. You can reduce the window even more by creating it with visible off: the documentation implies that it would still be temporarily made the current figure in that case, but it can be difficult to tell the cases apart.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!