Forcing a Cocoa app called from java to take focus
I have an OSX cocoa app that is called from my java like so:
String cmd = "/Users/mike/ASJPictureTaker.app/Contents/MacOS/ASJPictureTaker";
Runtime run = Runtime.getRuntime();
Process pr;
pr = run.exec(cmd);
开发者_JAVA百科pr.waitFor();
The ASJPictureTaker app loads and works fine but when the exec is called it does not take focus from the main app. Is there someway to tell the Cocoa app to steal focus when it is started up? Also, is there away for an application to not allow the user to switch to other applications until it is closed?
Not allowing the user to switch to other applications is called "kiosk mode" - and it's described here
This call did the trick:
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
精彩评论