Handling Opening Files
Joshua Smith
jesmith at kaon.com
Thu May 1 20:09:15 UTC 2014
I’ve finally bitten the bullet and moved over to Java 7 on Mac.
The only thing I’m stuck on is handling opening files when they are double-clicked in the Finder or dropped on my program in the Dock.
Are there any changes required to the file handling stuff in Info.plist for Java 7, or should one that worked with the previous Java still work?
Previously, I had this to handle the files:
com.apple.mrj.MRJApplicationUtils.registerOpenDocumentHandler(m);
Some googling revealed that now I need this:
com.apple.eawt.Application.getApplication().setOpenFileHandler(m);
Double-clicking the file is opening my app, but the OpenFileHandler is never called.
(Note that Application.getApplication().addApplicationListener(m) *is* working; I’m able to intercept Quit like I used to.)
If my program was not running, it opens. But no handler call.
If my program was already running, it pops to the foreground. But no handler call.
What’s the trick?
-Joshua
More information about the macosx-port-dev
mailing list