• 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
Metrics for a NSTextField
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Metrics for a NSTextField


  • Subject: Metrics for a NSTextField
  • From: Eric Gorr <email@hidden>
  • Date: Tue, 24 Feb 2009 15:13:17 -0500

I am attempting to get some measurements for the text being displayed in a NSTextField and am running into trouble.

It looks like all of the measurement methods are related to NSTextView.

I tried asking for a NSTextView for my NSTextField by doing the following:


NSTextView *fieldEditor = (NSTextView*)[[self window] fieldEditor:YES forObject:self];
NSLog( @"fieldEditor: %@", fieldEditor );
NSRect usedRect = [[fieldEditor layoutManager] usedRectForTextContainer:[fieldEditor textContainer]];
NSLog( @"usedRectForTextContainer: %@, %@", NSStringFromRect( usedRect ), [self stringValue] );



But the used rect returned is empty and [self stringValue] does contain a string of > 0 characters.



Is there something I am missing or is there an alternative way to get the information I am looking for?



_______________________________________________

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: Metrics for a NSTextField
      • From: Eric Gorr <email@hidden>
    • Re: Metrics for a NSTextField
      • From: Martin Wierschin <email@hidden>
  • Prev by Date: Strange NSManagedObjectContextObjectsDidChangeNotification behavior
  • Next by Date: [ANN] BWToolkit 1.1 IB Plugin: Codeless Split Views
  • Previous by thread: Re: Observing Managed Object Changes. Was: Strange ... behavior
  • Next by thread: Re: Metrics for a NSTextField
  • Index(es):
    • Date
    • Thread