Created
May 15, 2011 08:00
-
-
Save alexrozanski/972958 to your computer and use it in GitHub Desktop.
Reposition Traffic Lights
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
NSButton *closeButton = [self standardWindowButton:NSWindowCloseButton]; | |
NSView *themeFrame = [closeButton superview]; | |
CGFloat buttonYOrigin = NSMaxY(themeFrame.frame)-34; | |
//Alter the button frames | |
NSRect closeFrame = closeButton.frame; | |
closeFrame.origin.y = buttonYOrigin; | |
closeButton.frame = closeFrame; | |
/* (And do the same for the minimize and maximize buttons...) */ | |
//Get the tracking area used by the window's theme frame view | |
NSArray *trackingAreas = [themeFrame trackingAreas]; | |
if([trackingAreas count]>0) { | |
NSTrackingArea *trackingArea = [trackingAreas objectAtIndex:0]; | |
//Alter the tracking area rectangle | |
NSRect trackingRect = [trackingArea rect]; | |
trackingRect.origin.y = NSMinY(closeFrame); | |
//Create the new tracking area and set it on the window's theme frame view | |
NSTrackingArea *newTrackingArea = [[NSTrackingArea alloc] initWithRect:trackingRect | |
options:[trackingArea options] | |
owner:[trackingArea owner] | |
userInfo:[NSDictionary dictionary]]; | |
[themeFrame removeTrackingArea:trackingArea]; | |
[themeFrame addTrackingArea:newTrackingArea]; | |
[newTrackingArea release]; | |
} |
Oh, I have tried to set userInfo to [trackingArea userInfo]. Setting userInfo to [NSDictionary dictionary] is new for me.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well it worked with my implementation, yes. The key to it working, I found was to set the userInfo property on the tracking area to [NSDictionary dictionary].