Label does not respond to sizeToFit method

I’m trying to resize a label to match it’s content (text) using sizeToFit.
From what Apple describes, every NSControl (NSTextField, Label, …) responds to the sizeToFit method :

[quote]Resizes the receiver’s frame so that it is the minimum size needed to contain its cell
Declared in
The problem is
With Xcode, it simply works.

[label sizeToFit]

But with Xojo, it does not.


From the MBS docs: This method neither redisplays the receiver nor marks it as needing display. You must do this yourself with either thedisplay or setNeedsDisplay method.

Might be related to that.

I just tried it here in an open event of the label.


works fine. Just Xojo does not notice this, so you may need to tell xojo:

dim t as NSTextFieldMBS = me.NSTextFieldMBS t.sizeToFit me.Width = t.bounds.Width