Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get frame for NSStatusItem

Is it possible to get the frame of a NSStatusItem after I've added it to the status bar in Cocoa? When my app is launched, I am adding an item to the system status bar, and would like to know where it was positioned, is possible.

like image 772
marcc Avatar asked Mar 24 '11 01:03

marcc


2 Answers

The following seems to work - I have seen similar solutions for iOS applications and supposedly they permit submission to the app store because you are still using standard SDK methods.

    NSRect frame = [[statusBarItem valueForKey:@"window"] frame];
like image 178
Crutt Avatar answered Dec 12 '22 13:12

Crutt


You can use statusItem.button.superview?.window?.frame in swift

like image 40
Ethan SK Avatar answered Dec 12 '22 11:12

Ethan SK