mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 01:29:08 +02:00
Cocoa: TCocoaComboBox: keep text case after ItemIndex changed when cbactRetainPrefixCase set
This commit is contained in:
parent
ffe062f433
commit
b9b1f7f310
@ -1413,7 +1413,10 @@ begin
|
||||
if idx<0 then
|
||||
Result := NSNotFound
|
||||
else
|
||||
begin
|
||||
TComboBoxAsyncHelper.ResetTextIfNecessary(lclGetTarget, string_.UTF8String);
|
||||
Result := idx;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -57,6 +57,19 @@ type
|
||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||
end;
|
||||
|
||||
{ TComboBoxAsyncHelper }
|
||||
|
||||
TComboBoxAsyncHelper = class
|
||||
private
|
||||
cmb: TCustomComboBox;
|
||||
newText: String;
|
||||
procedure AsyncResetText(Data:PtrInt);
|
||||
public
|
||||
constructor Create(ACmb:TCustomComboBox; ANewText:String);
|
||||
public
|
||||
class procedure ResetTextIfNecessary(AObject:TObject; ANewText:String);
|
||||
end;
|
||||
|
||||
{ TLCLComboboxCallback }
|
||||
|
||||
TLCLComboboxCallback = class(TLCLCommonCallback, IComboBoxCallback)
|
||||
@ -705,6 +718,32 @@ begin
|
||||
allowed := TCustomCheckBox(Target).AllowGrayed;
|
||||
end;
|
||||
|
||||
{ TComboBoxAsyncHelper }
|
||||
|
||||
constructor TComboBoxAsyncHelper.Create(ACmb:TCustomComboBox; ANewText:String);
|
||||
begin
|
||||
cmb:= ACmb;
|
||||
newText:= ANewText;
|
||||
end;
|
||||
|
||||
procedure TComboBoxAsyncHelper.AsyncResetText(Data:PtrInt);
|
||||
begin
|
||||
TCocoaWSCustomComboBox.SetText(cmb, newText);
|
||||
cmb.SelStart:= UTF8Length(newText);
|
||||
cmb.SelLength:= 0;
|
||||
Free;
|
||||
end;
|
||||
|
||||
class procedure TComboBoxAsyncHelper.ResetTextIfNecessary(AObject:TObject; ANewText:String);
|
||||
var
|
||||
helper: TComboBoxAsyncHelper;
|
||||
ACmb: TCustomComboBox absolute AObject;
|
||||
begin
|
||||
if not (cbactRetainPrefixCase in ACmb.AutoCompleteText) then exit;
|
||||
helper:= TComboBoxAsyncHelper.Create(ACmb, ANewText);
|
||||
Application.QueueAsyncCall(@helper.AsyncResetText, 0);
|
||||
end;
|
||||
|
||||
{ TLCLComboboxCallback }
|
||||
|
||||
procedure TLCLComboboxCallback.ComboBoxWillPopUp;
|
||||
|
Loading…
Reference in New Issue
Block a user