Forum > Packages and Libraries
Unresponsive hints of TVirtualDrawTree + error in demo
trexet:
Hi.
Using Lazarus 3.4 and laz.virtualtreeview_package 5.5.3.1, found several problems with hints of TVirtualDrawTree.
First, the vst_advanced demo, DrawTreeDemo module, does not show hints at all, while the hints are supposed to be shown for Thumbnails column. Checking into the TBaseVirtualTree.CMHintShow, I found that the Hint property of VDT must be set as well.
Second, after fixing that, I do get hints now, but they are unresponsive:
1) Hints do not hide until I move the mouse out of the whole VDT or scroll (expected behavior is hiding the hint when moving mouse to another node/column)
2) Moving mouse from one hint-able cell straight to other hint-able cell keeps the old hint
3) Scrolling VDT so that mouse points to the hint-able cell does not show the hint
Third, I supposed that the demo hints are unresponsive because they are pretty labor-intensive, requiring scaling and rendering the bitmap. Thus I've implemented the hints in my program which do only the DrawText(), however, nothing changed at all.
So, I supposed that issue 1 can be partially fixed by setting the TBaseVirtualTree.HintData.HintInfo^.HideTimeout := 2000 during OnDrawHint. However, HintData is protected, so I put it right into TBaseVirtualTree.CMHintShow. Indeed that's a dirty trick, but at least hints became less annoying.
Another problem is that TVirtualDrawTree does not allow using system text hints and OnGetHint as the TVirtualStringTree does - that would be much easier for text hints.
wp:
Would you mind to write a bug report and add a patch?
Thaddy:
--- Quote from: wp on June 26, 2024, 06:14:20 pm ---Would you mind to write a bug report and add a patch?
--- End quote ---
and add a patch?
Never happens and in this case I don't believe the code is at fault, but the use:
This is code that has matured for over 20 years, so highly unlikely it does not work.
Mis- expectations about the virtual controls is very common, though.
trexet:
--- Quote from: Thaddy on June 26, 2024, 06:20:23 pm ---highly unlikely it does not work.
Mis- expectations about the virtual controls is very common, though.
--- End quote ---
You can check the vst_advanced demo and it's DrawTreeDemo module to make sure that
1) the demo is incorrect
2) either fixing the problem in demo reveals problems with VDT hints, or the demo demonstrates an incorrect use of VDT
--- Quote from: Thaddy on June 26, 2024, 06:20:23 pm ---This is code that has matured for over 20 years
--- End quote ---
On the other side, this is code that was developed for Windows XP. Anything may have changed, and judging by the demos, VDT does not get as much attention or use as VST, so some bugs may have been unnoticed.
--- Quote from: wp on June 26, 2024, 06:14:20 pm ---Would you mind to write a bug report and add a patch?
--- End quote ---
Sure I'll make a bug report and maybe even a patch for Hint field in the demo, however, I have no idea how to fix the hint behavior for VDT I fixed it - see post below.
I have no hope for it getting fixed, because
1) It's not a part of the LCL, and VDT is not widely used
2) The package doesn't seem to be maintained and synced to the original one (v5 is more than 10 years old, the latest is v8)
I've made a bug report into what I thought to be the package repo, but missed a bit :D
trexet:
Checking the demo further, I discovered that even the system-drawn hints and tooltips (GridDemo, WindowsXPStyleDemo) suffer from the described issue. Supposedly, that's how the Windows handles the mouse staying inside the same Control, but I may be wrong and just need to investigate mouse handling within VirtualTree further.
-----
However, I've made some progress on reducing the boilerplate code of drawing a simple text hint for the VDT. Currently, it makes no use of OnGetHindKind and vhkText, using vhkOwnerDraw by default. Thus, I added the TVTHintKind to TVTHintData, so it's preserved over CMHintShow() calls.
Next, I added OnGetHint to VDT, being called if TVTHintData.Kind = vhkText. And finally, inside TVirtualTreeHintWindow.CalcHintRect() I replaced
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- // The draw tree gets its hint size by the application (but only if not a header hint is about to show). // This size has already been determined in CMHintShow. if (Tree is TCustomVirtualDrawTree) and Assigned(Node) thenwith
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- // The draw tree gets its hint size by the application (but only if not a header or vhkText hint is about to show). // This size has already been determined in CMHintShow. if (Tree is TCustomVirtualDrawTree) and Assigned(Node) and (FHintData.Kind = vhkOwnerDraw) thenresulting in hint rect size being calculated automatically if TVTHintData.Kind = vhkText. Thus, OnGetHintSize is not required for the text hints in the VDT.
Next steps should be getting rid of OnDrawHint if vhkText is set, and trying to fix unresponsiveness if the cursor stays inside VT.
UPD: Removing OnDrawHint turned out to be pretty easy after previous changes - just added TVTHintData.Kind check to TVirtualTreeHintWindow.Paint():
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---if (Tree is TCustomVirtualDrawTree) and Assigned(Node) and (Kind = vhkOwnerDraw) thenThus, the cute system text hint is shown.
UPD2: Managed to fix unresponsiveness! (regardless of TVTHintData.Kind)
VT tracks which node/column is hovered (hot) in the TBaseVirtualTree.HandleHotTrack() (regardless to toHotTrack). It has a check if the hot node/column has changed, which can be extended for our purposes:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- if (HitInfo.HitNode <> FCurrentHotNode) or (HitInfo.HitColumn <> FCurrentHotColumn) then begin {...} // If we left the old hot node, then we should hide it's hint if ShowHint then Application.HideHint; end;Works like a charm for moving mouse over columns, however, to work as expected for rows (nodes), toFullRowSelect must be set. The reason for such requirement is an object to discover, and that's enough for today.
-----
If anyone would share the correct repository I should make a PR/send a patch to, I'd be grateful.
Navigation
[0] Message Index
[#] Next page