开发者

Getting the screen position of a non-view based NSStatusItem

My application makes use of an NSStatusItem. I need to grab the screen coordinates for the status item, but since I have no need for the functionality offered by setting a custom view for the item I am using a standard icon-b开发者_如何学Goased one instead.

Is there a way to get the status item's position without having to resort to setting a custom view to it?


Unless you find a better way, you could use some undocumented API: - (id)_window of NSStatusItem probably returns the window enclosing the item itself. Maybe you can get some interesting information out of that?

Beware: Some fundamentalists might actually try to break your neck for using undocumented API. Just make sure you check regularly if this portion of your code works with newer OS versions (either by hand or using some unit tests).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜