• 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
What rect does NSTextFieldCell use to draw its contents?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

What rect does NSTextFieldCell use to draw its contents?


  • Subject: What rect does NSTextFieldCell use to draw its contents?
  • From: Kyle Sluder <email@hidden>
  • Date: Mon, 10 Dec 2012 11:13:43 -0800

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 (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: What rect does NSTextFieldCell use to draw its contents?
      • From: "email@hidden" <email@hidden>
  • Prev by Date: Re: clarification about document type extensions
  • Next by Date: Re: How to implement readonly property
  • Previous by thread: Remote cursor and keyboard
  • Next by thread: Re: What rect does NSTextFieldCell use to draw its contents?
  • Index(es):
    • Date
    • Thread