Vscroll Property of a field that is scrolled to the end
Mark Schonewille
m.schonewille at economy-x-talk.com
Sun Jul 6 16:34:13 EDT 2008
Hi Sivakatirswami,
I have posted this a few times already, I guess it won't hurt if I
post it again.
The maximum scroll equals:
Code:
the formattedHeight of fld x - the height of fld x - the margins of
fld x - the textHeight of fld x
provided that the margins are an integer and the fixedLineHeight of
the field is true. If the margins are no integer, you probably need
to use item 4 of the margins. If the fixedLineHeight is not true, you
need to find a way to figure out the height of the last line of your
field. Also, the dontWrap of your field has to be set to true.
This is a nice way to do it:
Code:
getProp maxScroll
if word 1 of the name of the target is "field" then
return (the formattedHeight of the target - the height of the
target - the margins of the target - the textHeight of the target)
else return empty
end maxScroll
(untested, but should work)
Now, if you have this script at stack level or in a library, you can
call this property using:
Code:
put the maxScroll of fld x
set the vScroll of fld x to the maxScroll of fld x
The first line should return an integer, the second should set the
scroll of a field to the largest possible value.
--
Economy-x-Talk
Consultancy and Software Engineering
http://economy-x-talk.com
http://www.salery.biz
Get your store on-line within minutes with Salery Web Store software.
Download at http://www.salery.biz
Op 6-jul-2008, om 21:58 heeft Sivakatirswami het volgende geschreven:
> How do you get the vscroll of a field that would be scrolled all
> the way to the end, without actually scrolling it to the end?
>
> What I want to do is the "rolling credits" thing.
>
> This works
>
> CASE "About"
> put 1 into tAboutScroll
> REPEAT until the vscroll of fld "About" = 2714
> # the 2714 here is hard coded value...
> # I want to get it as a property regardless of what the field
> contains or it's size, font etc.
> set the vscroll of fld "About" to tAboutScroll
> put tAboutScroll +1 into tAboutScroll
> IF the mouseclick THEN exit repeat
> wait 1 ticks
> END repeat
> break
>
> But you have to customize that for every field... the 2714 is hard
> coded. I'm trying to get generic script that I can toss around from
> one stack to another and they still work...
>
>
> put the formattedheight of fld "song"-the height of fld "song"- the
> vscroll of fld "song"
>
> always returns 6... so one can calculate the ending vscroll value
> from this, if I have the field scrolled to the very end. Is this
> a "solid" algorithm:
>
> on scrollsong
> put 1 into tSongScroll
> put (the formattedheight of fld "song"-the height of fld "song"-
> 5) into tEnd
> REPEAT until the vscroll of fld "Song" = tEnd
>
> set the vscroll of fld "song" to tSongScroll
> put tSongScroll +1 into tSongScroll
> IF the mouseclick THEN exit repeat
> wait 5 milliseconds
> END repeat
> end scrollsong
>
> it feels like a bit of a hack....when I could be use some actual
> property.
>
>
> skts
>
More information about the use-livecode
mailing list