0

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. The part that I want to override is the NSButtonCell that I believe is drawing the "Arrow Button". Has anyone done this before, and if so, what method is used, so that I can change its appearance?

Are there any ways to know where to draw the NSButtonCell? (Can I override and install my own NSButtonCell?)

Thanks!

  • From the cocoa-dev mailing list: _James Walker wrote: 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._ This seems to work for me. Thanks James! – Bob-GlueTools Nov 22 '16 at 16:09

1 Answers1

0

From the cocoa-dev mailing list:

James Walker wrote: 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. This seems to work for me.

Thanks James!