LCL/Listview: Fix listview jumping to first item when a key is pressed in virtual mode, issue #39715.

This commit is contained in:
wp_xyz 2022-05-11 11:04:41 +02:00
parent 8c556536c1
commit d3396e9fa0

View File

@ -233,6 +233,26 @@ var
end;
end;
{ Workaround for issue #39715 to prevent the selection jumping to the first
item in virtual mode when a normal key is pressed (the listview probably
tries to perform an incremental search in this case which has not been
implemented, yet (handler for OnDataFind). }
procedure HandleListViewFindItem(ALV: TCustomlistViewAccess);
var
FindInfo: PNMLVFindItem;
listitem: TListItem;
begin
if ALV.OwnerData then
begin
FindInfo := PNMLVFindItem(NMHdr);
if Assigned(FindInfo) then
begin
MsgResult := -1;
WinProcess := false;
end;
end;
end;
begin
Result := False;
case Msg of
@ -247,6 +267,8 @@ begin
if ListViewWindProcInfo.ActiveListView = AWinControl then
ListViewWindProcInfo.NoMouseUp := True;
end;
LVN_ODFINDITEM:
HandleListViewFindItem(TCustomListViewAccess(AWinControl));
end;
end;
end;