I went back to this today to take it a step further and found my way blocked - it seems to be a MacRuby thing because this is trivial to implement in Objective-C. This code is now: framework 'Cocoa' class AppDelegate def initialize registerExperimental @eventDescriptor = NSAppleEventDescriptor.descriptorWithString("this_is_a_string") end def registerExperimental sharedAEManager = NSAppleEventManager.sharedAppleEventManager sharedAEManager.setEventHandler(self, andSelector: :"getURL:event:withReplyEvent:returnEvent", forEventClass: KInternetEventClass, andEventID:KAEGetURL) end def getURL(event, withReplyEvent:returnEvent) if event.respond_to?(:paramDescriptorForKeyword) url = event.paramDescriptorForKeyword(keyDirectObject).to_s end end def applicationShouldTerminateAfterLastWindowClosed(theApplication) return true; end end I've edited the info.plist to register 'experimental' as a custom URL scheme and tested it by calling it in Safari. Typing 'experimental://' in the Safari address bar produces an error: experimental[4759]: -[AppDelegate getURL:event:withReplyEvent:returnEvent]: unrecognised selector sent to instance 0x200c0e240 I've tried re-writing the 'andSelector: :"getURL:event:withReplyEvent:returnEvent"' part of the setEventHandler call every way I can think of: andSelector:"getURL:event:withReplyEvent:returnEvent" andSelector:"getURL:withReplyEvent" to name but two. I'm fairly sure the whole method name has to be sent, including the argument names, so I can't really see what is wrong. As I say, I've constructed the Obj-C equivalent (experimental-cpp) where typing 'experimental-cpp:///splat' produces exactly the required response. Any ideas anyone, please?
On Jan 11, 2011, at 4:30 PM, Martin Hawkins wrote:
def getURL(event, withReplyEvent:returnEvent) ... Typing 'experimental://' in the Safari address bar produces an error: experimental[4759]: -[AppDelegate getURL:event:withReplyEvent:returnEvent]: unrecognised selector sent to instance 0x200c0e240
Maybe this? getURL(url, event:event, withReplyEvent:replyEvent, returnEvent:returnEvent) ... end --- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
On 2011-01-11, at 14:30 , Martin Hawkins wrote:
sharedAEManager.setEventHandler(self, andSelector: :"getURL:event:withReplyEvent:returnEvent", forEventClass: KInternetEventClass, andEventID:KAEGetURL) …
def getURL(event, withReplyEvent:returnEvent)
So the selector for that method declaration would be: "getURL:withReplyEvent:" Notice the trailing colon.
Caio wins again! Thanks - I was sure I had tried that already. Need to be a bit more organised I think... Thanks again. On Jan 11, 4:49 pm, Caio Chassot <li...@caiochassot.com> wrote:
On 2011-01-11, at 14:30 , Martin Hawkins wrote:
sharedAEManager.setEventHandler(self, andSelector: :"getURL:event:withReplyEvent:returnEvent", forEventClass: KInternetEventClass, andEventID:KAEGetURL) …
def getURL(event, withReplyEvent:returnEvent)
So the selector for that method declaration would be:
"getURL:withReplyEvent:"
Notice the trailing colon.
_______________________________________________ MacRuby-devel mailing list MacRuby-de...@lists.macosforge.orghttp://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Caio Chassot
-
Joel Reymont
-
Martin Hawkins