NSTextView Resize Behavior

  • Hi all,

    I tried to understand how NSTextView works with NSScrollView,
    especially when wrapping disabled. My understanding is that NSTextView
    automatically grow its height (by default) and its width (need some
    tweak) according to users adding new line and adding new characters.

    So I did an experiment, creating a NSTextView without a containing
    NSScrollView, with the following settings (for a textview within a
    scrollview, the following code works well),

    [[_aView textContainer] setContainerSize:NSMakeSize(FLT_MAX, FLT_MAX)];
    [[_aView textContainer] setWidthTracksTextView:NO];
    [_aView setHorizontallyResizable:YES];
    [_aView setVerticallyResizable:YES];

    No surprisingly, the textview auto-grows its height when I kept
    inserting new lines. But it refuses to grow the width. What did I
    miss?

    Thanks,
    Dong
previous month june 2012 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