When a view contains an NSTextField
with the expansion tooltip enabled and the text doesn't fit, then the user hovers the cursor over the field, OS X shows an expansion tooltip. If you then call setStringValue:
to change the text content of the NSTextField
, the expansion tooltip's size is not updated. For instance, if the original text was 100 characters long but the new text is only 50 characters long, hovering over the new text will show an expansion tooltip large enough for 100 characters containing the new text. This is true even if the new string fits entirely in the NSTextField
, which normally would prevent an expansion tooltip appearing.
The opposite also occurs: If the original string fits within the NSTextField
, no expansion tooltip appears. If the new string does not fit within the NSTextField
, no expansion tooltip appears even though it should.
Internally, the NSTextField
's NSTextFieldCell
implements the NSCell
method expansionFrameWithFrame:inView:
. Something (I'm not sure what) calls this once, and seems to cache the result. Setting a new string using setStringValue:
does not cause this function to be called again.
Calling setNeedsDisplay
on the NSTextField after calling setStringValue:
does not fix this.
So how do I get AppKit to resize the expansion tooltip?