mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-24 08:39:33 +02:00
LCL/TCustomComboBox: CaseSensitive supported in RealSetText()
This commit is contained in:
parent
062bacda7a
commit
6d9db64d24
@ -456,12 +456,55 @@ begin
|
||||
I := ItemIndex;
|
||||
if (I < 0) or (I >= FItems.Count) or (FItems[I] <> AValue) then
|
||||
if not (csLoading in ComponentState) then
|
||||
ItemIndex := FItems.IndexOf(AValue);
|
||||
ItemIndex := MatchListItem(AValue);
|
||||
if AValue<>'' then
|
||||
HideEmulatedTextHint;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TCustomComboBox.MatchListItem(const AValue: TCaption): Integer;
|
||||
function match(matchText:String; itemText:String; caseSensitive:Boolean): Boolean;
|
||||
begin
|
||||
if caseSensitive then
|
||||
itemText := UTF8UpperCase(itemText);
|
||||
Result:= (matchText=itemText);
|
||||
end;
|
||||
var
|
||||
matchText: String;
|
||||
caseSensitive: Boolean;
|
||||
i: Integer;
|
||||
begin
|
||||
Result:= -1;
|
||||
if AValue='' then Exit;
|
||||
if FItems.Count=0 then Exit;
|
||||
caseSensitive:= cbactSearchCaseSensitive in AutoCompleteText;
|
||||
if caseSensitive then
|
||||
matchText:= AValue
|
||||
else
|
||||
matchText := UTF8UpperCase(AValue);
|
||||
if cbactSearchAscending in AutoCompleteText then
|
||||
begin
|
||||
for i := 0 to FItems.Count - 1 do
|
||||
begin
|
||||
if match(matchText, FItems[i], caseSensitive) then
|
||||
begin
|
||||
Result:= i;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end else
|
||||
begin
|
||||
for i := FItems.Count - 1 downto 0 do
|
||||
begin
|
||||
if match(matchText, FItems[i], caseSensitive) then
|
||||
begin
|
||||
Result:= i;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomComboBox.SetArrowKeysTraverseList(Value : Boolean);
|
||||
begin
|
||||
if Value <> FArrowKeysTraverseList then
|
||||
|
@ -409,6 +409,7 @@ type
|
||||
destructor Destroy; override;
|
||||
procedure IntfGetItems;
|
||||
procedure AddItem(const Item: String; AnObject: TObject); virtual;
|
||||
function MatchListItem(const AValue: TCaption): Integer;
|
||||
procedure AddHistoryItem(const Item: string; MaxHistoryCount: integer;
|
||||
SetAsText, CaseSensitive: boolean);
|
||||
procedure AddHistoryItem(const Item: string; AnObject: TObject;
|
||||
|
Loading…
Reference in New Issue
Block a user