Re: App Listener
Re: App Listener
- Subject: Re: App Listener
- From: <email@hidden>
- Date: Thu, 08 Jan 2009 19:24:49 +0000
>>On 2009 Jan, 07, at 22:46, Chunk 1978 wrote:
>>
>>>does this work with Dashboard? it seems that dashboard is a
>>>background application that's always open...
>>
>>Well, obviously it does not.
>>
>>You'd need a NSWorkspaceDidActivateApplicationNotification, but it looks like there is no such thing. You could periodically poll -[NSWorkspace activeApplication], but I hope someone has a
better idea, because if you do I would not want your process running on my Mac.
>
>Today, the only solution seems to be to install a Carbon Event handler for the {kEventClassApplication, kEventAppFrontSwitched} event.
Even better is to register for a Carbon Event handler for {kEventClassApplication, kEventAppLaunched} event. The user may switch the front application without launching an application. I think
the OP intends to be notified upon an application launch only.
>
>Even if such a NSWorkspace notification were to appear in a future version of Mac OS X, I'd be interested in a lower-level solution. I have a background process that can't link to AppKit due to
security restrictions, and Carbon Events have gone away for 64-bit processes.
This is not entirely true. There are a few APIs of the Carbon Event model who have been ported to 64-bit and have been made public in Leopard.
Examples:
InstallEventHandler
InstallEventLoopTimer
RegisterEventHotKey
ReleaseEvent
Examples of APIs which are not available to 64-bit applications:
QuitApplicationEventLoop
InstallStandardEventHandler
InstallEventLoopIdleTimer
I.e., APIs that are GUI-oriented are out, most APIs that provide core services are in.
So I guess the logic is: if you have an API in Cocoa, use it. If you don't, resort to Carbon Events that have been ported and retained for 64-bit applications.
HTH
Joao Varela
---- _______________________________________________
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