blikblum/VirtualTreeView-Lazarus

OnClick node does not fire if last visible node is selected, and hoVisible = true

Opened this issue · 4 comments

... given that there are enough nodes to fill the entire view window. VTV seems to have a "blind spot" approximately the height of the headers (just guessing ...) at the bottom of the VTV control's visible area. If I hide the headers, onClick works OK on all nodes.

Seems like the mouse hit test does not correctly take into account the size of the header. Observed on Windows 10, but also confirmed on QT/GTK2 by Theo and others (see German Lazarus Forum https://www.lazarusforum.de/viewtopic.php?f=18&t=13670)

Tested with Lazarus Built-in VTV and 5.5.3 - LCL2 and latest from SVN on Lazarus 2.0.12 / Windows 10

Steps to reproduce: use the enclosed sample. Klick any of the default nodes ans see onClick work in the status bar. Use the [+] button to add nodes until the last node (usually node 9) is inserted at the very bottom of the TreeView. Click it and you won't get any feedback from onClick in the status bar --> onClick has not fired.

There are variants like insert more nodes, scroll down the list to the very end and click the last node --> onClick won't fire.

Use the checkbox to hide the headers, and the problem is gone alltogether.

Armin.
VST Node onCLick problem
Source Code:
Last Node Hit Test.zip

wp has analysed the problem, and suggested a fix: https://www.lazarusforum.de/viewtopic.php?p=121955#p121955

With the fix, the onClick behaviour works like expected in my tests.

Found an existing bug report at the FreePascal Bugtracker:

https://bugs.freepascal.org/view.php?id=38482

Since this is a duplicate, It may be closed. I do, however, suggest you rise the priority, this bug makes the whole component unusable in some common situations.

This is the diff file of the change mentioned by arminlinder. It moves the top of the ClientRect down by the header height, rather than the bottom up: GetClientRect.diff.zip

On the other hand, ClientRect is a very fundamental quantity inside LCL/VCL controls, and I am doubtful whether this solution is correct. What at all is the reason that the tree excludes the header from the clientrect?

Agreed! Meanwhile there is IMHO a better solution for my problem: using OnNodeClick instead of onClick I got best results so far. Nodes fire correctly, and partially visible node scroll correctly into view, which they don't (at the bottom edge) with onClick + fix.

If it is true that onClick should fire whenever the visible area of the VirtualTree is clicked, regardless of whether it is the header or a node (both do have their own onClick handlers ...), removing the routine entirely seems the best fix. Who knows why this corrective code ( //lcl headers? WTF?) was introduced?.

My personal issue priority has shifted to low too, I don't have any issue with onNodeClick, and I have no need for onClick any more :-)