This always has been twisting my mind. In particular the inverted logic of HideSelection...
I am attaching a project in a Delphi and Lazarus version. There are checkboxes to toggle the RowSelect, HotTrack and HideSelection properties (HotTrack has been hard-wired to true in the Lazarus version, since the Delphi tree cannot be unthemed).
The observation that I make in Delphi:
- Toggling "HideSelection" between true and false toggles the visibility of the selected node, no matter what RowSelect and HotTrack are. The selection rectangle is gray.
- With HideSelection=false (i.e. show the selection when the tree is not focused) does not change the appearance of the selected node --> RowSelect does not work in Delphi
- Having HotTrack=true and moving the mouse over the nodes always shows the bright blue hottracked color, no matter whether HideSelection is on or off, or the tree is focused or not.
In the Lazarus version I see (without your patch from the previous post):
- Toggling "HideSelection", once the tree is no longer focused, never displays the selected node, no matter what RowSelect and HotTrack are. This is a bug.
- With HideSelection=false (i.e. show the selection when the tree is not focused) the gray selection rectangle is seen (correct), but only when RowSelect is false (--> bug). When HideSelection is true, no selection is displayed (see /1/).
- Having HotTrack=true and moving the mouse over the nodes shows the bright blue hottracked color when the tree is focused, and the gray hottracked color when the tree is not focused. I think this behaviour is more consistent than Delphi's blue selection even in the non-focused case.
After application of your patch, I see
- Toggling "HideSelection", once the tree is no longer focused, always displays the selection, as gray when HideSelection=true (there should be no selectionat all), or bright bordered blue when HideSelection= false (as if the tree were focused). Both are wrong.
- With HideSelection=false, RowSelect=true displays the full width selection (correct) (but no selection at all once HideSelection = true -- see /1/).
- HotTrack = true -- no change
Doing the same with Laz 3.8 we have
- Toggling "HideSelection" with tree unfocused always displays the selection, as gray. Gray is correct, but the selection should disappear when HideSelection becomes true.
- RowSelect=true always shows the full width selection (correct), bright bordered blue when the tree is focused (correct), gray when the tree is not selected (correct, but only when HideSelection=false -- see /1/).
- HotTrack=true - looks correct considering that the underlining used in Laz 3.8 applies only to the width of the caption and thus makes the choice of RowSelect ineffective.
So, there's still a lot to do (well, at least also the old version and Delphi have problems, too)...