NSTokenField how to make it horizontally scrollable

  • Hi,

    Is there anyone who can tell me how to make an NSTokenField(2 line height), included in a
    NSScrollView horizontally scrollable.

    I tried to use this delegate method:
    - (void)controlTextDidChange:(NSNotification *)aNotification;

    and used this code:

        NSRect frame;
    float width = 0.0;
    float height = 0.0;
    NSRect oldTokenFieldFrame = [locationTokenField frame];
    NSSize cellSize= [[locationTokenField cell] cellSizeForBounds:[locationTokenField
    bounds]];
    frame = NSMakeRect(oldTokenFieldFrame.origin.x,

    oldTokenFieldFrame.origin.y+oldTokenFieldFrame.size.height-cellSize.height,
            oldTokenFieldFrame.size.width,
            cellSize.height);
    width = fmaxf(width, NSWidth(frame));
    height = fmaxf(height, NSHeight(frame));
    frame.size.width += 10.0;
    [locationTokenField setFrame:frame];

        NSScrollView *scrollView = [locationTokenField enclosingScrollView];
        [scrollView setAutoresizingMask:NSViewHeightSizable];
        [scrollView setHasVerticalScroller:YES];
        [scrollView setHasHorizontalScroller:NO];

        frame = [[scrollView documentView] frame];
        frame.size.width = width;
        frame.size.height = height;
        [[scrollView documentView] setFrame:frame];
        [scrollView setNeedsDisplay:YES];

    But i couldn't accomplish what i was looking for ;-(
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today