Hi Ross,

Many thanks for the suggestion.

>> I tried saving the edited range of text in the text storage and then  
>> having my layout manager check this from:
>>
>> -textStorage:edited:range:changeInLength:invalidatedRange:
>>
>> Then my layout manager adds temp attribs in this method. Turns out  
>> that this is a Bad Thing (which I should have realised beforehand),  
>> as it can cause glyph generation before the text storage has ended  
>> editing. D'oh.

> I haven't tried fixing temporary attributes in NSTextStorage - 
> fixFontAttributeInRange:, but that might be worth a try.

Although it sounds like it should work, it doesn't unfortunately. Something 
very strange happens if you try to apply temporary attributes from 
-fixAttrubutesInRange: (or -fixFontAttributeInRange:) - the temporary 
attributes don't get displayed at all.

This seems way harder than it should be. I've now spent the best part of a week 
on essentially just trying to find the best way to apply temporary attributes 
to typed text without slowing everything down or causing crashes by 
intercepting things at the wrong time.

Although NSLayoutManager's -showPackedGlyphs:... provides the perfect override 
point for applying a different display colour to glyphs, there seems to be no 
good intercept point for changing the colour of underlines or strikethroughs.

For now, I have reverted to overriding 
-temporaryAttributesAtCharacterIndex:effectiveRange: and only changing the 
result if there is an underline or strikethrough at the passed-in index. Given 
that 10.6 provides a new delegate method, 
-layoutManager:shouldUseTemporaryAttributes:forDrawingToScreen:atCharacterIndex:effectiveRange:,
 which allows you to adjust temp attribs, I am guessing that this is the 
intended override after all, but that it is just hugely inefficient if you 
change the result too much... Though I'm unconvinced. Only more profiling will 
tell. :)

Many thanks again and all the best,
Keith



      
_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to