pageHeights ignores new line properties in fields?
I find that the pageHeights function does not take account of the
newer lines-in-fields properties like padding, spaceAbove,
spaceBelow, etc. If I set the scroll of the field to line 1 of the
pageHeights of that field, it will ordinarily put the first line of
"page 2" at the top of the field. But if I have, say, set the
padding of line 3 of that field to 15, setting the scroll in this way
may result in only the bottom half of a line of text appearing at the
top of the field. (It might accidentally work properly for some
cases, but trying a few different values illustrates the problem.)
Can anyone confirm this, and has anyone already scripted a workaround?
Re: pageHeights ignores new line properties in fields?
I took a quick look at the source of the 'pageHeights' property implementation and can confirm it's not taking these properties into account. And since the 'pageRanges' property implementation follows the same approach, I'm sorry to say that it won't take them into account either.
Not sure how you can script a workaround for this one. Maybe using the formattedHeight of individual line chunks, but that might not cover all corner cases. So I suggest you head on over to http://quality.runrev.com and create a bug entry.
Quartam Reports & PDF Library for LiveCode
"As we grow older, we grow both wiser and more foolish at the same time." (La Rochefoucauld)
On Wed, 1/15/14, David Epstein <[hidden email]> wrote:
Subject: pageHeights ignores new line properties in fields?
To: [hidden email] Date: Wednesday, January 15, 2014, 4:43 PM
I find that the pageHeights function
does not take account of the newer lines-in-fields
properties like padding, spaceAbove, spaceBelow, etc.
If I set the scroll of the field to line 1 of the
pageHeights of that field, it will ordinarily put the first
line of "page 2" at the top of the field. But if I
have, say, set the padding of line 3 of that field to 15,
setting the scroll in this way may result in only the bottom
half of a line of text appearing at the top of the
field. (It might accidentally work properly for some
cases, but trying a few different values illustrates the
Can anyone confirm this, and has anyone already scripted a
There is something really weird going wrong with mobileControlGet
for LiveCode in iOS. When I get the MaximumPixelLengthOfField it
first reports 15022. If I jump to that location to see the last line, I
discover that it really isn’t at the end of the field at all. After
physically scrolling down the rest of the field my pixel counter
tells me that the end is really at 18500 for the last line of text.
That wouldn’t be so bad, but then when I tell the field to scroll
back up to the top of the field and do the same thing again, this
time it will tell me that the end of the field is at 30217, even though
I started back at zero. If I jump back pixel 30217, the field isn’t at the
end, and I have to physically scroll down to the last line of text again
which ends up at yet another larger number.
Is this a know bug?
It is really screwing up my scaling process so that I can't know where
I am in the list.
put mobileControlGet("ListOfText", "contentRect") into VarContentRect
put item 4 of VarContentRect into VarMaximumPixelLengthOfField
Thanks to Jan Schenkel for the confirmation and suggestion.
Unfortunately, when I tried to script my own pageHeights function
using formattedHeight, I discovered that formattedHeight also gives
inaccurate results when paragraph properties have been set. I have
reported both of these problems as bug #11688.
The scripts below attempt to adjust for these inaccuracies, insofar
as I have been able to understand them. I am sure I have not
accounted for all cases, so amendments are welcome.
The first function reports the scroll values that will put each
complete paragraph (except the first) at the top of the field.
The second function is more directly comparable to the "pageHeights"
function, but it reports cumulative scroll values rather than the
height of each individual page.
function paragraphBottoms fid
-- report the values of scroll of field id fid that will put the
top of a full paragraph at the top of the field
-- returns a return delimited list. Each line reports
-- hScrollValue is a cumulative total, unlike the pageHeights
function, which reports height of each page
-- adjuster is the LC-reported value less the true value
repeat with n = 1 to the number of lines in fld id fid
add the spaceAbove of line n of fld id fid to a
if n > 1 then
add 2 * the padding of line n-1 of fld id fid to a
add 2 * the borderwidth of line n-1 of fld id fid to a
add the spaceBelow of line n-1 of fld id fid to a
get the formattedHeight of line 1 to n of fld id fid
put it-a & comma & a & return after myList
function lineBottoms fid
-- a return delimited list of hScroll values that will show field
-- content as consecutive "pages", each of which begins with a
-- be the wrapped continuation of a paragraph).
-- Reports a cumulative total, unlike the pageHeights function,
which reports height of each page
put the height of fld id fid - 2 * (the borderWidth of fld id fid
+ (the margins of fld id fid) - 8) into tgtH
put tgtH into h -- cumulative height target, increments as we go
put paragraphBottoms(fid) into pbList
repeat with p = 1 to the number of lines in pbList
if item 1 of line p of pbList < h then next repeat
-- Now work backwards from the bottom of para p, looking for the
-- visible line bottom < h
put length(line 1 to p of fld id fid) into c
put 2+length(line 1 to p-1 of fld id fid) into b
put empty into s
put item 2 of line p of pbList into a -- adjustment needed from
what LC reports as formattedHeight of para 1 to this para
add the borderWidth of line p of fld id fid to a
add the padding of line p of fld id fid to a
-- for chars in all but the last line of a bordered or padded
para, this further adjustment seems necessary
repeat with x = c down to b
get the formattedHeight of char 1 to x of fld id fid
if it - a < h then
put it-a into s
put s & return after newList
if s is empty then
if p > 1 then
get (item 1 of line p-1 of pbList)
if it is not line -1 of newList then
put it into s
else put h into s
else put h into s
-- i.e., if line is taller than h, accept a value that breaks
across the line
put s & return after newList
put s+tgtH into h