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

View File

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