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
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 个)

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by