Re: AppleEvents and modal dialogs
Re: AppleEvents and modal dialogs
- Subject: Re: AppleEvents and modal dialogs
- From: Uli Kusterer <email@hidden>
- Date: Sat, 9 May 2009 00:08:54 +0200
On 08.05.2009, at 21:16, James Walker wrote:
I have a mostly-Carbon app that runs some Cocoa modal dialogs using -
[NSApplication runModalForWindow:]. If an Apple Event (such as
'odoc') arrives while such a dialog is showing, it just gets eaten.
I'd like to have it either handled or deferred. I tried creating an
NSApplication delegate object, but its application:openFile: method
doesn't get called.
You probably need to install a kEventAppleEvent Carbon Event Handler
as described in CarbonEvents.h's entry on kEventClassAppleEvent /
kEventAppleEvent:
// If you need to handle this Carbon event yourself, the necessary
// steps are: (1) remove the Carbon event from the queue. The
// AppleEvent requires some special preparation before it can be
// processed, and this preparation only occurs when the event is
// dequeued. (2) Use ConvertEventRefToEventRecord to get an
// EventRecord from the Carbon event. (3) Call AEProcessAppleEvent
// on the EventRecord.
It appears that RunApplicationEventLoop() installs a handler for
this event, but in mixed Carbon/Cocoa applications, nobody installs
this on the Cocoa event loop (just like in WNE-based Applications that
call RunAppModalLoop()).
I don't remember all the details, but you may have to wait until
there actually *is* an event loop to install it on, i.e. do this in -
applicationDidFinishLaunching:, or even after each invocation to
runAppModalLoopForWindow (but before it returns).
Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden