开发者

Forcing a Cocoa app called from java to take focus

开发者 https://www.devze.com 2022-12-10 21:50 出处:网络
I have an OSX cocoa app that is called from my java like so: String cmd = \"/Users/mike/ASJPictureTaker.app/Contents/MacOS/ASJPictureTaker\";

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];

0

精彩评论

暂无评论...
验证码 换一张
取 消