Skip navigation.
 
mlRe: RTF pasting as plain text in NSTextView in some cases
FROM : Vince
DATE : Thu Feb 28 21:59:23 2008

Thanks Kyle,

It is RTF-editable. I created the NSTextView object manually because 
of other needs in the program.
It had been working properly for sometime, but I did some extensive 
improvements during the last couple of months; but this part of the 
code should have been unaffected.

I did implement:

- (void)setRichText:(BOOL)flag

It seems like should work, because the listing of acceptable Drag 
types included all of those that apply to RTF-editable at the end of 
the windowControllerDidLoadNib routine.

The behavior is very strange; I've been testing it and sometimes it 
goes into a plain text mode; other times it pastes fine as RTF. When 
I try to paste large file, say the Coca documentation on NSTextView, 
then it pastes it as plain text even it had been working ok before.

Thanks for the helpful suggestions below.
Any more insights are gratefully appreciated,

Vince

On Feb 28, 2008, at 2:45 PM, Kyle Sluder wrote:

> On Thu, Feb 28, 2008 at 11:32 AM, Vince <<email_removed>> wrote:

>> Hi,
>>
>>  My NSTextView has strange behavior when pasting: The rich text is
>>  pasted as plain text when the material has been copied from Safari.
>>  When the same material has been copied from another NSTextView 
>> (e.g.,
>>  TextEdit), it pastes properly as RTF.

>
> What are the options set on your NSTextView in IB?  It needs to be
> rich-text editable.
>

>>  I checked my pasteboard type at the end of the
>>  windowControllerDidLoadNib routine:
>>
>>        NSArray *arrDrag = [tView acceptableDragTypes];
>>        for(i=0;i<[arrDrag count];i++)
>>                NSLog(@"%@", [arrDrag objectAtIndex:i]);

>
> Dunno if this was a quick & dirty debug attempt or whatnot, but there
> are two style issues I'd like to highlight just as a note:
> 1) NSArray overrides -description to provide a reasonable string
> representation of its contents, so if you call NSLog(@"%@", arrDrag)
> things will Just Work(TM).
> 2) If you need something a bit fancier, instead of using the standard
> for-loop array idiom, it's recommended that you use an enumerator.  If
> you're targeting 10.4, use NSEnumerator.  If you're targeting 10.5,
> you can instead use the new for(foo in bar) syntax to take advantage
> of fast enumeration.
>
> HTH,
> --Kyle Sluder

Related mailsAuthorDate
mlRTF pasting as plain text in NSTextView in some cases Vince Feb 28, 17:32
mlRe: RTF pasting as plain text in NSTextView in some cases Kyle Sluder Feb 28, 20:45
mlRe: RTF pasting as plain text in NSTextView in some cases Vince Feb 28, 21:59