Talk About Network

Google





Mac > Mac Programmer Help > Re: Scrolling t...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 5 of 5 Topic 3678 of 3889
Post > Topic >>

Re: Scrolling text like a stock ticker

by Simon Slavin <slavins.delete.these.four.words@[EMAIL PROTECTED] Mar 30, 2008 at 07:58 PM

On 28/03/2008, flopbucket wrote in message <79d3e4eb-b1f1-4fc9-ac43-
d1da8b39c4ea@[EMAIL PROTECTED]
>:
 
> I want to write a small app that open a window and at the bottom has a
> scrolling text area, like a stock ticker.  As new data arrives, I want
> it to smoothly scroll in from the right, causing text at the extreme
> left to scroll out of the window.  Normal "ticker" type stuff.
> 
> Being new to Mac OS, I'm not exactly sure how best to go about this.
> Especially about getting the letters to smoothly scroll in (i.e. not
> whole letter at a time).  Do I draw to an offscreen bitmap and copy
> part of it to the window for display?

That's very oldschool.  There are better ways now.

In Cocoa, you will be writing your text to an NSTextView.

NSTextView inherits from NSView.

NSViews have two properties called 'frame' and 'bounds'.  Once controls
where the view appears in the view that contains it.  The other controls
where the contents of the view are drawn in relation to its boundaries. 
Normally they're the same but a good way to scroll content is to mess with
one, while leaving the other static.

I think one way to scroll your content (the text in an NSTextView) would
be to use setBounds continually.  Take a look at the do***entation for
NSView, and the conceptual doc here:

<http://developer.apple.com/do***entation/Cocoa/Conceptual/CocoaViewsGuide/
Coordinates/chapter_3_section_3.html>

Since you're relatively new to Cocoa I would suggest you handle your own
scrolling, because it will give you a good idea how Cocoa objects behave. 
But once you understand what's happening you might like to know that Cocoa
has an animation class especially designed for animating views:

<http://developer.apple.com/do***entation/Cocoa/Conceptual/AnimationGuide/A
rticles/ViewAnimations.html>

Simon.
-- 
http://www.hearsay.demon.co.uk
 




 5 Posts in Topic:
Scrolling text like a stock ticker
flopbucket <flopbucket  2008-03-28 16:05:31 
Re: Scrolling text like a stock ticker
David Phillip Oster <o  2008-03-29 11:27:50 
Re: Scrolling text like a stock ticker
flopbucket <flopbucket  2008-03-30 08:35:26 
Re: Scrolling text like a stock ticker
David Phillip Oster <o  2008-03-30 08:52:01 
Re: Scrolling text like a stock ticker
Simon Slavin <slavins.  2008-03-30 19:58:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Wed Jan 7 19:49:47 PST 2009.