Skip to content

Commit fa7d261

Browse files
committed
Merge pull request livecode#2808 from livecodeali/bugfix-15840
[[ Bug 15840 ]] Fix scrolling and display out-by-one irritations in tree view
2 parents 0ae3a4c + b16c203 commit fa7d261

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# [15840] Last line of widget not visible in readOnly false mode

extensions/widgets/treeview/treeview.lcb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,13 @@ public handler OnClick() returns nothing
682682
end handler
683683

684684
private handler yPosToRowNumber(in pYPos as Number) returns Integer
685-
return the floor of ((mViewTopPosition + pYPos) / mRowHeight + 1)
685+
variable tRow as Number
686+
put the floor of ((mViewTopPosition + pYPos) / mRowHeight + 1) into tRow
687+
if mReadOnly then
688+
add 1 to tRow
689+
end if
690+
691+
return tRow
686692
end handler
687693

688694
private handler xPosToIconString(in pXPos as Number) returns String
@@ -723,11 +729,7 @@ end handler
723729
// Clamp mViewTopPosition
724730
private handler ensureViewTopPosition()
725731
variable tMinTop as Real
726-
if mReadOnly then
727-
put mRowHeight into tMinTop
728-
else
729-
put 0 into tMinTop
730-
end if
732+
put 0 into tMinTop
731733

732734
// Make sure we don't try to scroll above 0
733735
if mViewTopPosition < tMinTop then
@@ -745,15 +747,18 @@ private handler updateFirstDataItem()
745747
put the floor of (mViewTopPosition / mRowHeight) + 1 into mFirstDataItem
746748
if mFirstDataItem < 1 then
747749
put 1 into mFirstDataItem
748-
end if
750+
end if
751+
if mReadOnly then
752+
add 1 to mFirstDataItem
753+
end if
749754
end handler
750755

751756
private handler updateParameters() returns nothing
752757
put the number of elements in mDataList into mDataCount
753758
if mReadOnly then
754-
put mRowHeight * mDataCount into mDataHeight
755-
else
756759
put mRowHeight * (mDataCount - 1) into mDataHeight
760+
else
761+
put mRowHeight * mDataCount into mDataHeight
757762
end if
758763
put my height into mViewHeight
759764
put my width into mViewWidth

0 commit comments

Comments
 (0)