开发者

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

开发者_如何学Python

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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜