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

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

Reply via email to