How do I bring a figure into focus programmatically in MATLAB on a Mac OS X machine?
4 次查看(过去 30 天)
显示 更早的评论
When I create a new figure, the focus is still on the MATLAB application even though the figure window is on top. To activate any buttons or interact with the figure in any way, I have to click on it once just to gain focus and then click on it again to interact with it. Is there a command to give the window focus without having to click on it?
For example, the following code generates a figure window in the foreground, but it doesn't gain focus until it is clicked:
plot(1:10)
采纳的回答
MathWorks Support Team
2009-6-27
This enhancement has been incorporated in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
The focus can be changed programmatically using Apple Script. Create a new file called "raiseX11.as" which contains the following three lines:
tell application "X11"
activate
end tell
To execute the script file, use the following command at the MATLAB prompt:
!osascript raiseX11.as
For example, to create a plot and then give it focus, enter the following commands:
plot(1:10)
!osascript raiseX11.as
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Visual Exploration 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!