LCL, LazControls: FilterEdit cleanup. Issue #40601, patch by n7800.

(cherry picked from commit 764415b6a0)
This commit is contained in:
Juha 2023-11-20 22:45:11 +02:00 committed by Maxim Ganetsky
parent 028cd6f117
commit d74ba1712b
4 changed files with 24 additions and 27 deletions

View File

@ -366,10 +366,12 @@ var
begin
if fFilteredListbox = nil then
exit(false);
Key:=Char(VK_RETURN);
Result:=Assigned(fFilteredListbox.OnKeyPress);
if Result then
begin
Key:=Char(VK_RETURN);
fFilteredListbox.OnKeyPress(fFilteredListbox, Key);
end;
end;
end.

View File

@ -333,10 +333,12 @@ var
begin
if fFilteredListview = nil then
exit(false);
Key:=Char(VK_RETURN);
Result:=Assigned(fFilteredListview.OnKeyPress);
if Result then
begin
Key:=Char(VK_RETURN);
fFilteredListview.OnKeyPress(fFilteredListview, Key);
end;
end;
end.

View File

@ -680,15 +680,17 @@ var
begin
if fFilteredTreeview = nil then
exit(false);
Key:=Char(VK_RETURN);
Result:=Assigned(fFilteredTreeview.OnKeyPress);
if Result then
begin
Key:=Char(VK_RETURN);
fFilteredTreeview.OnKeyPress(fFilteredTreeview, Key);
end;
end;
procedure TTreeFilterEdit.EditKeyDown(var Key: Word; Shift: TShiftState);
//
function AllowMultiSelectWithShift: Boolean;
function AllowMultiSelectWithShift: Boolean; inline;
begin
Result := (ssShift in Shift) and (msShiftSelect in fFilteredTreeview.MultiSelectStyle);
end;

View File

@ -1269,34 +1269,25 @@ begin
end;
procedure TCustomControlFilterEdit.EditKeyDown(var Key: Word; Shift: TShiftState);
var
Handled: Boolean;
begin
Handled:=False;
if Shift = [] then
case Key of
VK_RETURN: Handled:=ReturnKeyHandled;
VK_RETURN: if ReturnKeyHandled then Key := 0;
end;
if (Shift = []) or (Shift = [ssShift]) then
case Key of
VK_UP: begin MovePrev (ssShift in Shift); Key := 0; end;
VK_DOWN: begin MoveNext (ssShift in Shift); Key := 0; end;
VK_PRIOR: begin MovePageUp (ssShift in Shift); Key := 0; end;
VK_NEXT: begin MovePageDown(ssShift in Shift); Key := 0; end;
end;
if (Shift = [ssCtrl]) or (Shift = [ssCtrl, ssShift]) then
case Key of
VK_HOME: begin MoveHome(ssShift in Shift); Key := 0; end;
VK_END: begin MoveEnd (ssShift in Shift); Key := 0; end;
end;
if (Shift = []) or (Shift = [ssShift]) then
begin
case Key of
VK_UP: begin MovePrev(ssShift in Shift); Handled:=True; end;
VK_DOWN: begin MoveNext(ssShift in Shift); Handled:=True; end;
VK_PRIOR: begin MovePageUp(ssShift in Shift); Handled:=True; end;
VK_NEXT: begin MovePageDown(ssShift in Shift); Handled:=True; end;
end;
end;
if (Shift = [ssCtrl]) or (Shift = [ssCtrl, ssShift]) then
begin
case Key of
VK_HOME: begin MoveHome(ssShift in Shift); Handled:=True; end;
VK_END: begin MoveEnd(ssShift in Shift); Handled:=True; end;
end;
end;
if Handled then
Key:=VK_UNKNOWN
else
if Key <> 0 then
inherited EditKeyDown(Key, Shift);
end;