> On Mar 17, 2017, at 1:18 PM, Jeremy Hughes <moon.rab...@virginmedia.com> 
> wrote:
> 
> I have a text field that I want to grow and shrink while it is being edited.
> 
> In order to do that, I have overridden intrinsicContentSize and textDidChange 
> in a subclass of NSTextField:
> 
[SNIP]
> 
> This works, but if I remove the call to attributedStringValue (whose result 
> is discarded) the result of the following line fails to reflect changes in 
> the bounds of the text, and the field fails to grow or shrink.
> 
> Presumably, calling attributedStringValue has a side effect which changes the 
> way that cellSize:forBounds: is calculated.

Looking at the “attributedStringValue” docs, "validate​Editing()” is called as 
the side effect.

> Is there a way that I can get cellSize:forBounds: to return the correct value 
> without relying on this side effect?
> 
> An alternative way of calculating the intrinsic content size would be to use:
> 
> attributedStringValue.boundingRect(with: size, options: 
> .usesLineFragmentOrigin)
> 
> but this fails to take account of cell insets.

— 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com 


_______________________________________________

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