http://wiki.erights.org/mediawiki/index.php?title=User:Kevin_Reid/Mac_open_event_handler_test&feed=atom&action=historyUser:Kevin Reid/Mac open event handler test - Revision history2024-03-29T05:44:17ZRevision history for this page on the wikiMediaWiki 1.15.5-7http://wiki.erights.org/mediawiki/index.php?title=User:Kevin_Reid/Mac_open_event_handler_test&diff=2108&oldid=prevKevin Reid at 18:20, 1 October 20102010-10-01T18:20:16Z<p></p>
<p><b>New page</b></p><div>Can we have an [[E-on-Java]] app that handles Mac open events using the Apple Java extensions?<br />
<br />
This does the obvious thing, but doesn't actually receive open events. Perhaps there is a which-thread-is-the-listener-invoked-on problem?<br />
<br />
#!/usr/bin/env rune<br />
<br />
# For something that might work in SWT see https://www.kallisti.net.nz/trac/emusicj/browser/trunk/macsrc/nz/net/kallisti/emusicj/mac/OpenDocHandler.java (directly registering an AppleEvent handler)<br />
<br />
println("mainline a")<br />
interp.waitAtTop(when (currentVat.morphInto("awt")) -> {<br />
println("getting App")<br />
def app := <unsafe:com.apple.eawt.makeApplication>.getApplication()<br />
<br />
println("installing listener")<br />
app.addApplicationListener(def lis { <br />
to handleOpenFile(ev) { <br />
try {<br />
println(`got event $ev`)<br />
println(ev.getFilename())<br />
} catch p {<br />
println(`$p${p.eStack()}`)<br />
}<br />
} <br />
match msg {<br />
println(`got msg $msg`)<br />
}<br />
})<br />
println("all set")<br />
})<br />
println("mainline b; blocking")<br />
interp.blockAtTop()<br />
<br />
==History==<br />
<br />
* Written 2008-01-28.<br />
* Last experimented with 2009-05-12.<br />
* Published here 2010-10-01.</div>Kevin Reid