質問

I need to measure a string width to make space (vertically) if more than the horizontal available space is needed. I can do this on a NSTextField, but on a NSTokenField ?

役に立ちましたか?

解決 2

Here is an answer I found elsewhere:

- (void)resizeTokenField;
{
    NSRect oldTokenFieldFrame = [self.tokenField frame];
    NSSize cellSize= [[self.tokenField cell] cellSizeForBounds:[self.tokenField
                                                           bounds]];


        [self.tokenField setFrame:NSMakeRect(
                                        oldTokenFieldFrame.origin.x,
                                        oldTokenFieldFrame.origin.y+ oldTokenFieldFrame.size.height-
                                        cellSize.height,
                                        oldTokenFieldFrame.size.width,
                                        cellSize.height)];

}

他のヒント

NSTokenField inherits from NSTextField (and other classes on top mentioned in the documentation), so it should be no problem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top