Bron Davies
Bron Davies

Reputation: 6004

How do you re-order a window to be on top of all others in cocoa?

I want my application to become the top-level window on the OSX desktop when it needs to display important information. How would you go about doing this in cocoa?

Upvotes: 0

Views: 558

Answers (2)

Peter Hosey
Peter Hosey

Reputation: 96323

I want my application to become the top-level window …

You can't, because an application is not a window.

… it needs to display important information. How would you go about doing this in cocoa?

Send the NSApplication object a requestUserAttention: message. The user will activate your application in their own time (e.g., after they finish typing their password in somewhere).

Upvotes: 0

theMikeSwan
theMikeSwan

Reputation: 4729

You mean you want to hijack the user's screen? Can you not just call requestUserAttention: on NSApplication? If you really must hijack the screen then look into setLevel: in NSWindow. Just keep in mind that any user like myself is going to delete your application as soon as you hijack the screen unless there is a very good reason to do so. Whenever you are thinking about doing things like this look at http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines/XHIGIntro/XHIGIntro.html first, then decide if it is the right course of action.

Upvotes: 2

Related Questions