It's my understanding that the intent of NSStringDrawing is to provide
the exact same drawing as NSTextFieldCell. But the following code
produces text that is offset by 2pt to the left from a standard
NSTextFieldCell:

@implementation MyTextFieldCell /* : NSTextFieldCell */

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView
*)controlView {
    NSStringDrawingOptions options = 0;
    if (self.truncatesLastVisibleLine)
        options |= NSStringDrawingTruncatesLastVisibleLine;
    if (!self.usesSingleLineMode)
        options |= NSStringDrawingUsesLineFragmentOrigin;
    
    [self.attributedString drawWithRect:[self
    titleRectForBounds:cellFrame] options:options];
}

@end

I can't tell if I'm using the wrong rect or failing to pass the right
arguments to -drawWithRect:options:. Anyone have any clues?

--Kyle Sluder
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to