How do I bring a figure into focus programmatically in MATLAB on a Mac OS X machine?
4 views (last 30 days)
Show older comments
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)
Accepted Answer
MathWorks Support Team
on 27 Jun 2009
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 Comments
More Answers (0)
See Also
Categories
Find more on Visual Exploration in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!