Thank you, James! This works great! Using an auto-scroll in a one line 
high field is an approach I hadn´t thought of. A very well written 
behavior it is, too! Thanks for taking time to write such a complete 
behavior.

> Hi Mats,
>
> Here's a behavior that will do what you want by setting the scrollTop 
> of the
> field or text member that the text appears in.  To change the text, you 
> can
> use:
>
>   sendSprite(x, #mSetText, "your new string")
>
> Cheers,
>
> James
>
>
> ----------------------------------------------------------------------------
>
> -- SWAP LINES --
> --
> -- Simulates the way the LCD display in a cell phone will show a long
> -- line of text in short chunks.
>
>
>
> -- PROPERTY DECLARATIONS --
>
> property delay
>
> property pMember
> property pScroll
> property pLineHeight
> property pTimeOut
>
>
>
> -- EVENT HANDLERS --
>
> on beginSprite(me)
>   -- Initialize properties
>   pMember = sprite(me.spriteNum).member
>   pScroll = 0
>
>   -- Set the properties of the member so that the behavior will work
>   pMember.boxType   = #fixed
>   pMember.wordWrap  = TRUE
>   pMember.scrollTop = 0
>
>   -- Set the height of the sprite to show only one line of text
>   case pMember.type of
>     #field:
>       pLineHeight  = pMember.lineHeight
>       tRect        = pMember.rect
>       tRect.bottom = tRect.top + pLineHeight
>       pMember.rect = tRect
>
>     #text:
>       pMember.topSpacing     = 0
>       pLineHeight            = pMember.charPosToLoc(1).locV + 1
>       pMember.height         = pLineHeight
>       pMember.fixedLineSpace = 0
>   end case
>
>   -- Create a timeOut object to swap the lines on a regular basis
>   pTimeOut = timeOut(string(me)).new(delay, #mSwapLine, me)
> end beginSprite
>
>
>
> on endSprite(me)
>   -- Prevent memory leaks
>   pTimeOut.target = 0
>   pTimeOut.forget()
> end endSprite
>
>
>
> -- PUBLIC METHODS --
>
> on mSetText(me, aString) ---------------------------------------------
>   -- INPUT:  <aString> should be a string
>   -- ACTION: Restarts the swap line cycle with a new text string
>   --------------------------------------------------------------------
>
>   if stringP(aString) then
>     -- Reintitialize text display
>     pMember.text      = aString
>     pMember.scrollTop = 0
>     pScroll           = 0
>
>     -- Reinitialize timeOut
>     pTimeOut.target   = 0
>     pTimeOut.forget()
>     pTimeOut          = timeOut(string(me)).new(delay, #mSwapLine, me)
>   end if
> end mSetString
>
>
>
> on mSwapLine(me) -----------------------------------------------------
>   -- SENT BY: pTimeOut
>   -- ACTION:  Shows the next line of text after the chosen delay
>   --------------------------------------------------------------------
>
>   tHeight = pMember.height - pLineHeight
>
>   if not tHeight then
>     -- There are no additional lines to swap in
>     pTimeOut.period = 0
>   else if pScroll < tHeight then
>     -- Scroll down to the next line
>     pScroll = pScroll + pLineHeight
>   else
>     -- Scroll back up to the beginning
>     pScroll = 0
>   end if
>
>   pMember.scrollTop = pScroll
> end mSwapLine
>
>
>
> -- PARAMETERS --
>
> on getPropertyDescriptionList(me)
>   tPropertyList = [:]
>
>   tPropertyList[ \
> #delay] = [ \
>  #comment: "Milliseconds during which each line is shown", \
>  #format:  #integer, \
>  #range:  [#min: 0, #max: 10000], \
>  #default: 1000 \
> ]
>
>   return tPropertyList
> end getPropertyDescriptionList
>
> [To remove yourself from this list, or to change to digest mode, go to 
> http://www.penworks.com/lingo-l.cgi  To post messages to the list, 
> email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). 
> Lingo-L is for learning and helping with programming Lingo.  Thanks!]
>

[To remove yourself from this list, or to change to digest mode, go to 
http://www.penworks.com/lingo-l.cgi  To post messages to the list, email 
[EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED]). Lingo-L is for 
learning and helping with programming Lingo.  Thanks!]

Reply via email to