开发者

Getting the screen position of a non-view based NSStatusItem

开发者 https://www.devze.com 2023-03-26 11:39 出处:网络
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 a

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

精彩评论

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

关注公众号