• 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: Don Willems <email@hidden>
  • Date: Thu, 25 Nov 2004 13:32:31 +0100

I did both!
I used a superview for the background image.
And I had to create subclasses of NSButton and NSPopUpButton for the thin lines between the buttons (to separate them).


I'm not completely satisfied with the result yet. It seems that the border-less NSPopUpButton draws the arrows right next to the far right of its frame, causing the separator line to be drawn in contact with the arrows. It needs some tweeking.

The biggest problem now is highlighting, if I click a button, the button background becomes white, not aqua blue.

Thanks,
Don




On 25 Nov 2004, at 12:00, Michael Becker wrote:

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: Michael Becker <email@hidden>
References: 
 >background of NSButton and NSPopUpButton (From: Don Willems <email@hidden>)
 >Re: background of NSButton and NSPopUpButton (From: Michael Becker <email@hidden>)

  • Prev by Date: Re: Using AEBuild commands to send IM to iChat and AIM
  • Next by Date: Re: What's wrong with this code?
  • Previous by thread: Re: background of NSButton and NSPopUpButton
  • Next by thread: Re: background of NSButton and NSPopUpButton
  • Index(es):
    • Date
    • Thread