Created
October 6, 2012 16:38
-
-
Save karstenBriksoft/3845417 to your computer and use it in GitHub Desktop.
getting the coordinates of a status item
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on code from http://the-useful.blogspot.de/2012/01/getting-nsstatusitem-co-ordinates.html | |
@implementation NSStatusItem (Position) | |
- (NSRect)frame | |
{ | |
if (self.view) | |
{ | |
return [[self.view window] frame]; | |
} | |
NSImage* image = self.image; | |
NSImage* alternateImage = self.alternateImage; | |
id target = self.target; | |
SEL action = self.action; | |
BOOL highlightMode = self.highlightMode; | |
NSRect viewFrame = NSZeroRect; | |
viewFrame.size = image.size; | |
NSView *statusBarView = [[NSView alloc] initWithFrame: viewFrame]; | |
self.view = statusBarView; | |
NSRect rect = [[statusBarView window] frame]; | |
self.view = nil; | |
self.image = image; | |
self.alternateImage = alternateImage; | |
self.highlightMode = highlightMode; | |
self.action = action; | |
self.target = target; | |
return rect; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment