• 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: background of NSButton and NSPopUpButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: background of NSButton and NSPopUpButton


  • Subject: Re: background of NSButton and NSPopUpButton
  • From: Michael Becker <email@hidden>
  • Date: Thu, 25 Nov 2004 12:00:29 +0100

Hi!

Am 25.11.2004 um 11:20 schrieb Don Willems:
Now I'm thinking of subclassing NSButtonCell and NSPopUpButtonCell, but I'm not sure how to go about that.

Just subclass e.g. NSPopUpButton. This is itself an NSView-subclass, so you can just override drawRect: like this:


- (void)drawRect:(NSRect)cellFrame {
	// Creating a red background
	[[ NSColor redColor] set];
	NSRectFill([self bounds]);

	[[ self cell] drawWithFrame:cellFrame inView:self];
}

The call to drawWithFrame:inView: will draw the PopUpButton. If you want it to look like in the "bar" in Xcode, set the PopUpButton to be not bordered.
Personally, though, I would go with your first idea (creating a background view and placing non-bordered buttons on it) because this way you can be sure that there are no graphical differences between your button's background and the rest.


Cheers,
Michael

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: background of NSButton and NSPopUpButton
      • From: Don Willems <email@hidden>
References: 
 >background of NSButton and NSPopUpButton (From: Don Willems <email@hidden>)

  • Prev by Date: getting a list of connected displays
  • Next by Date: Re: Using AEBuild commands to send IM to iChat and AIM
  • Previous by thread: background of NSButton and NSPopUpButton
  • Next by thread: Re: background of NSButton and NSPopUpButton
  • Index(es):
    • Date
    • Thread