Re: NSAppleEventManager
Re: NSAppleEventManager
- Subject: Re: NSAppleEventManager
- From: Jeffrey J Barbose <email@hidden>
- Date: Wed, 8 Aug 2001 17:40:03 -0700
it's actually REALLY easy to use NSAppleEventManager.
the call is along the lines of:
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:myMainWindowController
andSelector:@selector(methodOfControllerForEvent:andReplyEvent:)
forEventClass:'Foo_' andEventID:'Bar_'];
any obj-c object can be the handler, it just has to have a
method/selector that is of the form:
- (void) handleTheEvent:(NSAppleEventDescriptor*)inEvent
andReplyWith:(NSAppleEventDescriptor*)replyEvent;
the eventClass and eventID are the same pattern as for AEhandlers in classic.
that's really all there is to it, to get an incoming AE mapped to a
message at runtime....LOTS more flexible than bare functionptr
callbacks.
oh, and this applescript might come in handy for testing:
tell application "MyApp"
+event Foo_Bar_;
end tell
where the call is bracketed by left and right double-angle-brackets
(opt-\ and shift-opt-\, respectively)
just set a breakpoint in the method you specified as your selector,
and run the applescript. easy test for targeting.
At 4:13 PM -0700 8/8/01, Michael Emfinger wrote:
Hi,
I've read everything on this board regarding NSAppleEvents and I've looked
at the cocoa headers (NSAppleEventDescriptor,NSAppleEventManager) and I was
wondering if anyone had any sample code for installing a handler. Also, I
wanted to use my main window controller as my handler, which is also the
application delegate. Is this okay?
Any help is much appreciated, as I need to get my new app responding to
Apple Events.
Thanks in advance,
Michael
_______________________________________________
cocoa-dev mailing list
email@hidden
http://www.lists.apple.com/mailman/listinfo/cocoa-dev