Re: NSPanel, changing the look of the min button
Re: NSPanel, changing the look of the min button
- Subject: Re: NSPanel, changing the look of the min button
- From: Tony Romano <email@hidden>
- Date: Tue, 3 Aug 2010 13:51:22 -0700
Thanks Uli, couldn't see the forest through the trees! This is how I implemented it and it seems to work quite well.
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle
backing:(NSBackingStoreType)bufferingType defer:(BOOL)deferCreation
{
self = [super initWithContentRect:contentRect styleMask:windowStyle backing:bufferingType defer:deferCreation];
// Hide the standard minimize and zoom buttons
NSButton *button = [self standardWindowButton:NSWindowZoomButton];
[button setHidden:YES];
button = [self standardWindowButton:NSWindowMiniaturizeButton];
[button setHidden:YES];
// Determine where the old min button was located and make that the location for the triangle
// At this point, the toolbar has not been added to the frame, update the frame in awakeFromNib
NSRect minFrame = [button frame];
NSView *superView = [button superview];
// Create the new disclosure triangle button
disclosureTriangle = [[NSButton alloc] initWithFrame:minFrame];
// Set the style
[disclosureTriangle setBezelStyle:NSDisclosureBezelStyle];
[disclosureTriangle setButtonType:NSOnOffButton];
[disclosureTriangle setBordered:YES];
// Make sure title is an empty string to show the triangle properly
[disclosureTriangle setTitle:@""];
// Setup Target=First Responder / Action
[disclosureTriangle setAction:@selector(showOrHideInspector:)];
[disclosureTriangle setTarget:nil];
// Finally add it to the view hierarchy. Need to leave the old min button there because the theme frame expects it be there.
[superView addSubview:disclosureTriangle];
[disclosureTriangle release];
return self;
}
-(void) awakeFromNib
{
NSButton *button = [self standardWindowButton:NSWindowMiniaturizeButton];
NSRect minFrame = [button frame];
minFrame.origin.y +=1;
[disclosureTriangle setFrame:minFrame];
}
-Tony
On Aug 3, 2010, at 6:46 AM, Uli Kusterer wrote:
> Am 03.08.2010 um 00:31 schrieb Tony Romano:
>> Changing the argument to the correct flag gets me the button, however, setting the style doesn't have any effect. I moved the code to initWithContentRect: post the call to super, still no change. I introspected the view with F-Script and it has the bezel style I set but the window still draws the standard widget. Any other ideas?
>
> Have you tried hiding that button and creating your own button to put in its place?
>
> -- Uli Kusterer
> "The Witnesses of TeachText are everywhere..."
>
>
>
>
-Tony
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden