But i noticed another thing that s unexpected:
if there is only one item in the list )think of a folder containing only one file):
if you select this, then click on empty space ..... -> the item keeps to be selected.
Normally you won't see that at all. Unless when using ownerdraw! being dependent here on referrable matching objects and properties.
So a test project is here attached that does simply some related IFs on mouse click.
Btw, that all didn't happen with the 2.0.12
Tried to fix it too and that does what it is expected to do, but an expert would do it conceptually cleaner correcting the real cause. Couldn't go deeper as i ran out of time now.
On top of Patch GetMem July 28, 2021:
customlistview.inc, around line 350:
// select state changed
if (nm^.uNewState and LVIS_SELECTED) = 0 then
begin
if not OwnerData then
begin
if FSelected = Item then
InvalidateSelected
end else
if (nm^.iItem < 0) or (nm^.iItem = FSelectedIdx) then
// InvalidateSelected;
// ---- Patch attempts d7_2_laz ----
begin
// Patch #1: problem Selected is nil, although items are selected by ArrowDown/ArrowUp:
if not MultiSelect then // <- addistional condition
InvalidateSelected;
// Patch #2: problem: after click on emptry space single item keeps to stay selected
if (MultiSelect And (nm^.iItem < 0)) then
if Assigned(FListItems[0]) then
FListItems[0].Selected:=False;
end;
// ---- End patch d7_2_laz ----
end else