On Jan 31, 2012, at 1:55 AM, Gerriet M. Denkmann wrote:

> I have an app A, where I can select a word and press a button.
> This starts (or activates) another app called B, which displays some 
> information about this word.

> But if there is no information about the word, app B should make app A active 
> again.
> But how?
> (B should not be hidden; it should remain visible, so that the user sees: 
> "Word not found".)

> There probably is a simple, direct and obvious solution. But I cannot see it.

There isn't, as far as I know.  The best general-purpose solution I'm aware of 
is for app B to track activations of other apps using Carbon events 
(kEventClassApplication , kEventAppFrontSwitched).  Then, use that info to 
switch back to the last activate app.

I suppose, these days, you can also key-value observe the runningApplications 
property of [NSWorkspace sharedWorkspace] to learn when apps come and go, and 
then key-value observe the active property of all of the NSRunningApplication 
objects in that collection to track which was last active.  That doesn't seem 
like much of an improvement over the Carbon events approach, though.

However, your case seems more specific.  Are both apps A and B ones that you're 
writing?  Can't you just switch back to app A directly, if it's the only thing 
that will be invoking app B?  Or have I misunderstood your case (in which case, 
maybe you could clarify).

Regards,
Ken


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to