Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Activate app but bring only *one* window to the front
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Activate app but bring only *one* window to the front



On 2011 Jun 29, at 10:11, Kyle Sluder wrote:

> -[NSRunningApplication activateWithOptions:]

Thank you, Kyle, that works.  Indeed, in Mac OS 10.6+, the code

[[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps] ;

activates the app, but only brings forward the key/main window(s), as desired.  (My actual code is longer since this app uses the 10.5 SDK.  10.5 users will get all windows activated.)

However, Cocoa still wins.  My purpose was to show an alert-type of window (my own custom version of NSAlert) without bringing forward a document window.  Initially, it works, but when the user clicks a button which sends -[NSWindow close] to the alert window, the document window is brought forward, even if I try and tell it "no" by deactivating the app…

NSLog(@"Will close alert window in 5 seconds") ;
sleep(5) ;
[NSApp deactivate] ;
[[self window] close] ;
[NSApp deactivate] ;
NSLog(@"Did close alert window.  Will continue in 5 seconds") ;
sleep(5) ;

That test shows that it's definitely -[NSWindow close] which brings the next window forward, not -[NSApp stopModal] or -[NSApp endModalSession].

_______________________________________________

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

References: 
 >Activate app but bring only *one* window to the front (From: Jerry Krinock <email@hidden>)
 >Re: Activate app but bring only *one* window to the front (From: Kyle Sluder <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.