How to get the on-screen location of an NSStatusItem

前端 未结 7 708
暖寄归人
暖寄归人 2020-12-05 01:27

I have a question about the NSStatusItem for cocoa in mac osx. If you look at the mac app called snippets (see the movie at http://snippetsapp.com/). you will s

7条回答
  •  生来不讨喜
    2020-12-05 01:51

    To do this without the hassle of a custom view, I tried the following (that works). In the method that is set as the action for the status item i.e. the method that is called when the user clicks the status item, the frame of the status item can be retrieved by:

    [[[NSApp currentEvent] window] frame]
    

    Works a treat for me

提交回复
热议问题