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

2011-06-30 Thread Jerry Krinock

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

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


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

2011-06-30 Thread Scott Ribe
On Jun 30, 2011, at 2:39 PM, Jerry Krinock wrote:

 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…

That's the way windowing behavior is defined in OS X. When the frontmost 
regular window is closed, the next window of that app is made frontmost.

Sounds like you need a floating/utility window of some flavor.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
(303) 722-0567 voice




___

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

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


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

2011-06-30 Thread Ken Thomases
On Jun 30, 2011, at 3:39 PM, Jerry Krinock wrote:

 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.)

For what it's worth, that new method is simply the Cocoa equivalent of 
SetFrontProcessWithOptions with kSetFrontProcessFrontWindowOnly.  So, you can 
use the latter for 10.5 compatibility.

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

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


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

2011-06-29 Thread Jerry Krinock
• App is running with several windows open but is not frontmost.
• It receives an interapplication message which requires that a new window be 
opened and brought to the front.

-[NSApplication activateIgnoringOtherApps:] brings *all* of app's windows to 
the front.

How can I activate this app but bring *only* the new window to the front?  
Other windows should remain at their current order.

Thank you,

Jerry Krinock

___

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

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


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

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:07 AM, Jerry Krinock je...@ieee.org wrote:
 • App is running with several windows open but is not frontmost.
 • It receives an interapplication message which requires that a new window be 
 opened and brought to the front.

 -[NSApplication activateIgnoringOtherApps:] brings *all* of app's windows to 
 the front.

 How can I activate this app but bring *only* the new window to the front?  
 Other windows should remain at their current order.

Never tried it, but +[NSRunningApplication activateWithOptions:] looks
promising.

--Kyle Sluder
___

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

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


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

2011-06-29 Thread Kyle Sluder
On Wed, Jun 29, 2011 at 10:11 AM, Kyle Sluder kyle.slu...@gmail.com wrote:
 Never tried it, but +[NSRunningApplication activateWithOptions:] looks
 promising.

Er, make that -[NSRunningApplication activateWithOptions:]. Combine
that with +[NSRunningApplication currentApplication].

--Kyle Sluder
___

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

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