mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 16:39:19 +02:00
Cocoa: Fix #40528: Initialize TComboBox correctly according to Index when Style=csDropDownList
This commit is contained in:
parent
664c88804c
commit
fd23b819bd
@ -63,11 +63,14 @@ type
|
|||||||
private
|
private
|
||||||
cmb: TCustomComboBox;
|
cmb: TCustomComboBox;
|
||||||
newText: String;
|
newText: String;
|
||||||
|
private
|
||||||
procedure AsyncResetText(Data:PtrInt);
|
procedure AsyncResetText(Data:PtrInt);
|
||||||
|
procedure AsyncSetLastIndex(Data:PtrInt);
|
||||||
public
|
public
|
||||||
constructor Create(ACmb:TCustomComboBox; ANewText:String);
|
constructor Create(ACmb:TCustomComboBox);
|
||||||
public
|
public
|
||||||
class procedure ResetTextIfNecessary(AObject:TObject; ANewText:String);
|
class procedure ResetTextIfNecessary(AObject:TObject; ANewText:String);
|
||||||
|
class procedure SetLastIndex(AObject:TObject);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TLCLComboboxCallback }
|
{ TLCLComboboxCallback }
|
||||||
@ -722,10 +725,9 @@ end;
|
|||||||
|
|
||||||
{ TComboBoxAsyncHelper }
|
{ TComboBoxAsyncHelper }
|
||||||
|
|
||||||
constructor TComboBoxAsyncHelper.Create(ACmb:TCustomComboBox; ANewText:String);
|
constructor TComboBoxAsyncHelper.Create(ACmb:TCustomComboBox);
|
||||||
begin
|
begin
|
||||||
cmb:= ACmb;
|
cmb:= ACmb;
|
||||||
newText:= ANewText;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TComboBoxAsyncHelper.AsyncResetText(Data:PtrInt);
|
procedure TComboBoxAsyncHelper.AsyncResetText(Data:PtrInt);
|
||||||
@ -736,16 +738,33 @@ begin
|
|||||||
Free;
|
Free;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TComboBoxAsyncHelper.AsyncSetLastIndex(Data:PtrInt);
|
||||||
|
begin
|
||||||
|
TCocoaWSCustomComboBox.SetItemIndex(cmb, TCocoaReadOnlyComboBox(cmb.Handle).lastSelectedItemIndex);
|
||||||
|
Free;
|
||||||
|
end;
|
||||||
|
|
||||||
class procedure TComboBoxAsyncHelper.ResetTextIfNecessary(AObject:TObject; ANewText:String);
|
class procedure TComboBoxAsyncHelper.ResetTextIfNecessary(AObject:TObject; ANewText:String);
|
||||||
var
|
var
|
||||||
helper: TComboBoxAsyncHelper;
|
helper: TComboBoxAsyncHelper;
|
||||||
ACmb: TCustomComboBox absolute AObject;
|
ACmb: TCustomComboBox absolute AObject;
|
||||||
begin
|
begin
|
||||||
if not (cbactRetainPrefixCase in ACmb.AutoCompleteText) then exit;
|
if not (cbactRetainPrefixCase in ACmb.AutoCompleteText) then exit;
|
||||||
helper:= TComboBoxAsyncHelper.Create(ACmb, ANewText);
|
helper:= TComboBoxAsyncHelper.Create(ACmb);
|
||||||
|
helper.newText:= ANewText;
|
||||||
Application.QueueAsyncCall(@helper.AsyncResetText, 0);
|
Application.QueueAsyncCall(@helper.AsyncResetText, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
class procedure TComboBoxAsyncHelper.SetLastIndex(AObject:TObject);
|
||||||
|
var
|
||||||
|
helper: TComboBoxAsyncHelper;
|
||||||
|
ACmb: TCustomComboBox absolute AObject;
|
||||||
|
begin
|
||||||
|
helper:= TComboBoxAsyncHelper.Create(ACmb);
|
||||||
|
Application.QueueAsyncCall(@helper.AsyncSetLastIndex, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TLCLComboboxCallback }
|
{ TLCLComboboxCallback }
|
||||||
|
|
||||||
procedure TLCLComboboxCallback.ComboBoxWillPopUp;
|
procedure TLCLComboboxCallback.ComboBoxWillPopUp;
|
||||||
@ -1886,7 +1905,8 @@ begin
|
|||||||
rocmb.list:=TCocoaReadOnlyComboBoxList.Create(rocmb);
|
rocmb.list:=TCocoaReadOnlyComboBoxList.Create(rocmb);
|
||||||
rocmb.setTarget(rocmb);
|
rocmb.setTarget(rocmb);
|
||||||
rocmb.setAction(objcselector('comboboxAction:'));
|
rocmb.setAction(objcselector('comboboxAction:'));
|
||||||
rocmb.selectItemAtIndex(rocmb.lastSelectedItemIndex);
|
rocmb.lastSelectedItemIndex:= -1;
|
||||||
|
TComboBoxAsyncHelper.SetLastIndex(AWinControl);
|
||||||
rocmb.callback:=TLCLComboboxCallback.Create(rocmb, AWinControl);
|
rocmb.callback:=TLCLComboboxCallback.Create(rocmb, AWinControl);
|
||||||
Result:=TLCLIntfHandle(rocmb);
|
Result:=TLCLIntfHandle(rocmb);
|
||||||
rocmb.isOwnerDrawn := ComboBoxIsOwnerDrawn(TCustomComboBox(AWinControl).Style);
|
rocmb.isOwnerDrawn := ComboBoxIsOwnerDrawn(TCustomComboBox(AWinControl).Style);
|
||||||
|
Loading…
Reference in New Issue
Block a user