• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
AppleEvent handlers don't seem to work.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AppleEvent handlers don't seem to work.


  • Subject: AppleEvent handlers don't seem to work.
  • From: Martin Redington <email@hidden>
  • Date: Wed, 14 Jun 2006 16:49:30 +0100


Background ...

I want my app when opened normally, to create one kind of untitled document, but under certain circumstances, to create a different kind of document.

My plan is to send a pass thru argument to the app via LSLaunchURLSpec, to over-ride the normal behaviour.

I would like to be able to use this, and to get a new "special" untitled doc, even when the App is already running.

====

My understanding is that my app will receive an apple event from LSLaunchURLSpec, and that I can inspect this AppleEvent, to see if my passthrough arg os present or not.

=====

So, I tried installing new kAEOpenApplication, kAEReopenApplication, and kAEOpenDocuments handlers, in my controller's awakeFromNib method, like so:

NSAppleEventManager *appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self
andSelector:@selector (handleOpenApplicationEvent:withReplyEvent:)
forEventClass:kCoreEventClass
andEventID:kAEOpenApplication];


[appleEventManager setEventHandler:self
andSelector:@selector (handleOpenApplicationEvent:withReplyEvent:)
forEventClass:kCoreEventClass
andEventID:kAEReopenApplication];


[appleEventManager setEventHandler:self
andSelector:@selector (handleOpenApplicationEvent:withReplyEvent:)
forEventClass:kCoreEventClass
andEventID:kAEOpenDocuments];



but my event handler:

- (void) handleOpenApplicationEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
{
NSLog(@"******** handleOpenApplicationEvent called *********");
}


never seems to get called. For example, if I background the app, and then click on its doc icon (which should send a reopen, nothing happens). Ditto, if I run

tell application "TestAppleEvents"
	open "~/Desktop/text.txt"
end tell

I get nothing (I have added <key>NSAppleScriptEnabled</ key><string>YES</string> to the Info.plist).

Am I doing something wrong here?

    cheers,
          Martin







_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: AppleEvent handlers don't seem to work.
      • From: Annard Brouwer <email@hidden>
  • Prev by Date: Calculating Desktop Icon Positions
  • Next by Date: Re: Preference Pane vs NSTimer/NSThread
  • Previous by thread: Re: Calculating Desktop Icon Positions
  • Next by thread: Re: AppleEvent handlers don't seem to work.
  • Index(es):
    • Date
    • Thread