• 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: NSComboBoxCell subclass pointers?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSComboBoxCell subclass pointers?


  • Subject: Re: NSComboBoxCell subclass pointers?
  • From: James Walker <email@hidden>
  • Date: Mon, 21 Nov 2016 17:46:04 -0800

On 11/20/2016 8:15 PM, Robert Monaghan wrote:
I have been working on a custom UI for my Cocoa application. By looking around the internet, I have managed to learn how to subclass a large number of UI objects on MacOSX. In many cases I could make the appearance work the way I want.

The last UI element that I am working on, is NSComboBoxCell. It appears to be a NSTextFieldCell with an NSButtonCell attached. It seems fairly easy to override
“drawWithFrame:inView"  and draw a replacement artwork. But there are a bunch of unknowns/pitfalls..

The part that I suspect that I have to subclass is the NSButtonCell that I believe is drawing the "Arrow Button”.
But how is this done, along side the NSTextField that makes up the NSComboBoxCell class? When I look at the NSComboBoxCell header files, I don’t see any obvious clues to figure out the geometry of the NSButtonCell, that is apparently being used alongside the NSTextField, itself.

Are there any ways to get to the NSButtonCell stored inside the NSComboBoxCell Object? (Ideally so that I can override and install my own NSButtonCell..)

In my NSComboBoxCell subclass, I figured out where the "button" part ought to be as follows:

NSRect drawingRect = [self drawingRectForBounds: cellFrame];
NSRect titleBounds = [self titleRectForBounds: drawingRect];
NSRect buttonBounds = NSMakeRect( NSMaxX( titleBounds ),
	NSMinY(drawingRect),
	NSMaxX(drawingRect) - NSMaxX( titleBounds ),
	NSHeight(drawingRect) );

And then I drew my own button content.
_______________________________________________

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


  • Follow-Ups:
    • Re: NSComboBoxCell subclass pointers?
      • From: Robert Monaghan <email@hidden>
References: 
 >NSComboBoxCell subclass pointers? (From: Robert Monaghan <email@hidden>)

  • Prev by Date: Re: Swift DispatchQueue docs?
  • Next by Date: AutoSave for Windows
  • Previous by thread: NSComboBoxCell subclass pointers?
  • Next by thread: Re: NSComboBoxCell subclass pointers?
  • Index(es):
    • Date
    • Thread