[Lazarus] Collapse/Expand "bug" in VirtualTreeView "fixed".

Jürgen Hestermann juergen.hestermann at gmx.de
Wed Aug 24 12:33:53 CEST 2016

Am 2016-08-24 um 11:04 schrieb Jürgen Hestermann:
 > I have changed my VirtualTreeView.pas file now and the bug is gone.
 > So if anybody encounters the same problem (and IMO it must be
 > everybody who uses hierarchical nodes when the main column
 > is *not* the most left one) ...
 > Another question is, why GetHitTestInfoAt searches for a non-empty
 > cell while VTV does not even know how such cells are defined.
 > I don't see any rational behind it.

It seems that I have overlooked that all my observations only apply
if (toAutoSpanColumns in FOptions.FAutoOptions) is true.
That may explain why this issue has not popped up earlier.
I have set toAutoSpanColumns a long time ago but meanwhile do all
the drawing myself so it does not matter to me whether it is set or not.

Nevertheless, the searching for non-empty cells is only useful if the event
routine OnGetCellIsEmpty has been defined by the programmer.
If he did not do this, all cells are considered to be empty which makes no sense.
Therefore IMO this if-request in GetHitTestInfoAt

if toAutoSpanColumns in FOptions.FAutoOptions then

needs to be enhanced by checking the OnGetCellIsEmpty routine:

if (toAutoSpanColumns in FOptions.FAutoOptions) and
    assigned(FOnGetCellIsEmpty) then

If FOnGetCellIsEmpty=nil, then the checking for empty cells should
be skipped in the same way as if toAutoSpanColumns is not set.
It makes no sense to check for empty cells when all cells are
always considered to be empty.

And IMO the bug still exists that *if* the code for searching non-empty
cells is run, then it does not do this correctly when searching to the
right as HitColumn is not changed in this case.

And also I still think that the result of ColumnIsEmpty should
default to false,  not true. It would avoid confusion and unexpected results.

More information about the Lazarus mailing list