Bug reported to [EMAIL PROTECTED]
FntGetScrollValues returns a value one too big in topLineP some of the time. This
routine is used by FldGetScrollValues, making it return a value one too big in
scrollPosP. FldGetScrollValues is used by many applications to compute how to update
the scroll bar associated with a field, causing bugs in scroll bar behavior.
Which versions of Palm OS have this bug:
* Palm OS 2.0 and later, including 3.1.
* Bug is not in Palm OS 1.0 because it doesn't have scroll bars.
Scenario:
* Go to the Memo Pad application.
* Choose the small font.
* Enter the numbers from 1 to 13, one number per line, entering the return stroke
between each number, but not after the last number. You now have 13 lines of text in a
field which displays only 11 lines at a time (in the small font).
* Drag the scroll car up until the number 2 is at the top of the screen, then release
the scroll car. The car will appear just a bit below the top, since only a single line
is off the top of the field.
* Tap to place the insertion point just to the left of the number 3, and enter the
backspace stroke followed by the return stroke. These strokes will delete and then
re-insert a return (actually, a linefeed) into the field. The number 2 is still at the
top of the screen, so the scroll bar should look the same as it did before this step.
Instead, the scroll car will be at the bottom, in the position it should be in when
the number 3 is at the top of the screen.
* Try to drag the scroll car down. You can't scroll down to see the number 13 without
scrolling up first.
Workaround:
Use the following "fixed" routines in place of FntGetScrollValues and
FldGetScrollValues:
void FixedFntGetScrollValues(const Char * const chars, const Word width, const Word
scrollPos, const WordPtr linesP, const WordPtr topLineP)
{
Word topLine, length;
FntGetScrollValues(chars, width, scrollPos, linesP, &topLine);
if (scrollPos > 0 && chars[scrollPos - 1] == linefeedChr)
topLine--;
length = StrLen(chars);
if (length > 0 && length <= scrollPos && chars[length - 1] == linefeedChr)
topLine++;
*topLineP = topLine;
}
void FixedFldGetScrollValues(const FieldPtr fld, const WordPtr scrollPosP, const
WordPtr textHeightP, const WordPtr fieldHeightP)
{
Word scrollPos, firstVisible, length;
CharPtr chars;
FldGetScrollValues(fld, &scrollPos, textHeightP, fieldHeightP);
chars = FldGetTextPtr(fld);
firstVisible = FldGetScrollPosition(fld);
if (firstVisible > 0 && chars[firstVisible - 1] == linefeedChr)
scrollPos--;
length = StrLen(chars);
if (length > 0 && length <= firstVisible && chars[length - 1] == linefeedChr)
scrollPos++;
*scrollPosP = scrollPos;
}
-
Danny Epstein * mailto:[EMAIL PROTECTED]
Applied Thought Corporation * http://www.appliedthought.com
Flytrap for PalmOS * http://www.appliedthought.com/flytrap