• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSPanel, changing the look of the min button
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >NSPanel, changing the look of the min button (From: Tony Romano <email@hidden>)
 >Re: NSPanel, changing the look of the min button (From: Kyle Sluder <email@hidden>)
 >Re: NSPanel, changing the look of the min button (From: Tony Romano <email@hidden>)
 >Re: NSPanel, changing the look of the min button (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Using NSNotificationCenter passing an object or value?
  • Next by Date: Re: Threading and Event Queue Question
  • Previous by thread: Re: NSPanel, changing the look of the min button
  • Next by thread: Re: NSPanel, changing the look of the min button
  • Index(es):
    • Date
    • Thread