FROM : Mike Ferris
DATE : Tue Dec 31 19:46:03 2002
Ah, so when I said you can't just change the color object, of course
that was incorrect if you do something like Greg suggests ;-).
Mike
Begin forwarded message:
> From: Greg Titus <<email_removed>>
> Date: Tue Dec 31, 2002 10:29:38 AM US/Pacific
> To: Daryn <<email_removed>>
> Cc: <email_removed>
> Subject: Re: Dynamic color changes in a text view
>
> On Tuesday, December 31, 2002, at 10:11 AM, Daryn wrote:
>
>> I have a text view that contains text with various configurable
>> colors. Using a continous color well, I'd like the existing text to
>> change color.
>>
>> My thoughts about how to implement this would involve adding my own
>> attributes (ie. "MyRedColor", "MyGreenColor", etc) to the text
>> storage in order to use attribute:atIndex:effectiveRange: to iterate
>> over the storage and update the color.
>>
>> Is there a simpler method to achieve this result? For example, is it
>> possible to conceptually change a single color object that all the
>> colored ranges use?
>
> Make your own custom subclass of NSColor and set instances of that
> subclass as the colors on your text. Implement the -set method to call
> -set on a real NSColor object with whatever color is appropriate at
> that moment.
>
> Then all you should need to do is tell your text view
> -setNeedsDisplay:YES when your colors change, and the existing objects
> in the text storage will cause the right colors to be used when the
> view is redrawn.
>
> Hope this helps,
> - Greg
> _______________________________________________
> cocoa-dev mailing list | <email_removed>
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
DATE : Tue Dec 31 19:46:03 2002
Ah, so when I said you can't just change the color object, of course
that was incorrect if you do something like Greg suggests ;-).
Mike
Begin forwarded message:
> From: Greg Titus <<email_removed>>
> Date: Tue Dec 31, 2002 10:29:38 AM US/Pacific
> To: Daryn <<email_removed>>
> Cc: <email_removed>
> Subject: Re: Dynamic color changes in a text view
>
> On Tuesday, December 31, 2002, at 10:11 AM, Daryn wrote:
>
>> I have a text view that contains text with various configurable
>> colors. Using a continous color well, I'd like the existing text to
>> change color.
>>
>> My thoughts about how to implement this would involve adding my own
>> attributes (ie. "MyRedColor", "MyGreenColor", etc) to the text
>> storage in order to use attribute:atIndex:effectiveRange: to iterate
>> over the storage and update the color.
>>
>> Is there a simpler method to achieve this result? For example, is it
>> possible to conceptually change a single color object that all the
>> colored ranges use?
>
> Make your own custom subclass of NSColor and set instances of that
> subclass as the colors on your text. Implement the -set method to call
> -set on a real NSColor object with whatever color is appropriate at
> that moment.
>
> Then all you should need to do is tell your text view
> -setNeedsDisplay:YES when your colors change, and the existing objects
> in the text storage will cause the right colors to be used when the
> view is redrawn.
>
> Hope this helps,
> - Greg
> _______________________________________________
> cocoa-dev mailing list | <email_removed>
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | <email_removed>
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
| Related mails | Author | Date |
|---|---|---|
| Daryn | Dec 31, 19:11 | |
| Greg Titus | Dec 31, 19:29 | |
| Mike Ferris | Dec 31, 19:44 | |
| Mike Ferris | Dec 31, 19:46 | |
| Daryn | Dec 31, 20:17 | |
| Daryn | Dec 31, 21:39 | |
| Greg Titus | Dec 31, 21:52 | |
| Mike Ferris | Jan 2, 17:14 |






Cocoa mail archive

