Re: output string like a teleprinter (NSTextView)
Re: output string like a teleprinter (NSTextView)
- Subject: Re: output string like a teleprinter (NSTextView)
- From: Graham Cox <email@hidden>
- Date: Fri, 18 Dec 2015 10:34:59 +1100
> On 18 Dec 2015, at 1:49 AM, sqwarqDev <email@hidden> wrote:
>
> A couple of years ago I was messing around with NSTextView and NSTextStorage and accidentally ended up with a method that printed my string (could have been attributed string) to my textview one character at a time, rather like an old fashioned teleprinter.
>
> At the time, that wasn’t the effect I wanted, and so I quickly replaced the code that was causing the “trouble”.
>
> Ha. Well, of course, now today I need exactly that effect, but I can’t for the life of me figure out how I had managed to accidentally get that to occur.
If it happened accidentally it was most likely due to setting up a situation that caused extreme low performance rather than triggering a designed-in (but undocumented) effect.
>
> Can anyone offer any pointers?
You could just gradually add characters from the original string to a ‘display’ string using a timer and ask a standard layout manager/text view etc. to re-lay and draw the display string. Using a custom NSLayoutManager is another way to go - it gives you the opportunity to override almost any aspect of layout. If you need less complex layout features, you could also do it using Core Text. But just incremening a string and redrawing it in a textview is really by far the simplest approach.
—Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden