mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 18:20:34 +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
|
if idx<0 then
|
||||||
Result := NSNotFound
|
Result := NSNotFound
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
|
TComboBoxAsyncHelper.ResetTextIfNecessary(lclGetTarget, string_.UTF8String);
|
||||||
Result := idx;
|
Result := idx;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -57,6 +57,19 @@ type
|
|||||||
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
class procedure SetFont(const AWinControl: TWinControl; const AFont: TFont); override;
|
||||||
end;
|
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 }
|
||||||
|
|
||||||
TLCLComboboxCallback = class(TLCLCommonCallback, IComboBoxCallback)
|
TLCLComboboxCallback = class(TLCLCommonCallback, IComboBoxCallback)
|
||||||
@ -705,6 +718,32 @@ begin
|
|||||||
allowed := TCustomCheckBox(Target).AllowGrayed;
|
allowed := TCustomCheckBox(Target).AllowGrayed;
|
||||||
end;
|
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 }
|
{ TLCLComboboxCallback }
|
||||||
|
|
||||||
procedure TLCLComboboxCallback.ComboBoxWillPopUp;
|
procedure TLCLComboboxCallback.ComboBoxWillPopUp;
|
||||||
|
Loading…
Reference in New Issue
Block a user