NSTextView subclass - paste into table cell breaks table?

  • I have an NSTextView subclass. I've overridden -
    readSelectionFromPasteboard:type: so that I can perform a "filter" on
    the attributed string before pasting/dropping it into the text view.

    I think I've implemented the method correctly according to the docs.
    (If I haven't, where have I gone wrong?)

    BEGIN CODE SNIPPET:

    /* if the type is interesting, and we got some data off the
    pasteboard */

    NSAttributedString *attributedString = [[[NSAttributedString alloc]
    initWithPasteboard: pboard options: nil documentAttributes: NULL
    error: &error] autorelease];
    if (attributedString == nil) {
    return NO;
    }

    attributedString =  /* do some processing on the string */

    NSRange range = [self rangeForUserTextChange];
    if ([self shouldChangeTextInRange: range replacementString:
    [attributedString string]]) {
    [[self textStorage] replaceCharactersInRange: range
    withAttributedString: attributedString];
    [self didChangeText];
    }

    ==END

    When I paste the text into a table cell (top middle in the example)
    it "breaks" the table.

    Have I done something wrong, or am I running into a bug? In either
    case, is there any corrective action I can take?

    Thanks,
    Jim
previous month october 2006 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 31          
Go to today