Cocoa: CaseSensitive supported in TCocoaComboBox.comboBox_indexOfItemWithStringValue()

This commit is contained in:
rich2014 2023-06-14 23:46:05 +08:00
parent 6d9db64d24
commit 85afe93ad6
2 changed files with 13 additions and 3 deletions

View File

@ -447,6 +447,8 @@ function GetFieldEditor(afield: NSTextField): TCocoaFieldEditor;
implementation
uses CocoaWSStdCtrls;
function GetFieldEditor(afield: NSTextField): TCocoaFieldEditor;
var
lFieldEditor: TCocoaFieldEditor;
@ -1407,8 +1409,7 @@ begin
Result:=idx
else
begin
// todo: consider a faster search?
idx := list.IndexOf(string_.UTF8String);
idx := TCocoaWSCustomComboBox.GetObjectItemIndex(aComboBox.lclGetTarget);
if idx<0 then
Result := NSNotFound
else

View File

@ -76,6 +76,7 @@ type
TCocoaWSCustomComboBox = class(TWSCustomComboBox)
public
class function getNSText(const ACustomComboBox: TCustomComboBox): NSText;
class function GetObjectItemIndex(const AObject: TObject): integer;
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
class procedure SetBorderStyle(const AWinControl: TWinControl; const ABorderStyle: TBorderStyle); override;
@ -1931,6 +1932,14 @@ begin
Result:= txt.selectedRange.length;
end;
class function TCocoaWSCustomComboBox.GetObjectItemIndex(const AObject: TObject): integer;
begin
if AObject is TCustomComboBox then
Result:= GetItemIndex( TCustomComboBox(AObject) )
else
Result:= -1;
end;
class procedure TCocoaWSCustomComboBox.SetSelStart(
const ACustomComboBox: TCustomComboBox; NewStart: integer);
var
@ -1973,7 +1982,7 @@ begin
if ComboBoxStyleIsReadOnly(ACustomComboBox.Style) then
idx := TCocoaReadOnlyComboBox(ACustomComboBox.Handle).indexOfSelectedItem
else
idx := TCocoaComboBox(ACustomComboBox.Handle).indexOfSelectedItem;
idx := ACustomComboBox.MatchListItem(ACustomComboBox.Text);
if idx = NSNotFound then
Result := -1
else