mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-06 10:00:34 +02:00
LCL & Cocoa: fix the bugs in TCustomComboBoxEx/TCocoaWSCustomComboBox
This commit is contained in:
parent
f99643fe6d
commit
9490d8cdc6
@ -301,7 +301,7 @@ end;
|
|||||||
procedure TCustomComboBoxEx.AddItem(const Item: String; AnObject: TObject);
|
procedure TCustomComboBoxEx.AddItem(const Item: String; AnObject: TObject);
|
||||||
begin
|
begin
|
||||||
Insert(ItemsEx.Count, Item);
|
Insert(ItemsEx.Count, Item);
|
||||||
ItemsEx[ItemsEx.Count].Data:=AnObject;
|
ItemsEx[ItemsEx.Count-1].Data:=AnObject;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomComboBoxEx.AssignItemsEx(AItemsEx: TComboExItems);
|
procedure TCustomComboBoxEx.AssignItemsEx(AItemsEx: TComboExItems);
|
||||||
|
@ -300,6 +300,8 @@ type
|
|||||||
{ TCocoaReadOnlyComboBoxList }
|
{ TCocoaReadOnlyComboBoxList }
|
||||||
|
|
||||||
TCocoaReadOnlyComboBoxList = class(TCocoaComboBoxList)
|
TCocoaReadOnlyComboBoxList = class(TCocoaComboBoxList)
|
||||||
|
private
|
||||||
|
FId: Integer;
|
||||||
protected
|
protected
|
||||||
FOwner: TCocoaReadOnlyComboBox;
|
FOwner: TCocoaReadOnlyComboBox;
|
||||||
procedure InsertItem(Index: Integer; const S: string; O: TObject); override;
|
procedure InsertItem(Index: Integer; const S: string; O: TObject); override;
|
||||||
@ -323,6 +325,7 @@ type
|
|||||||
|
|
||||||
isOwnerDrawn: Boolean;
|
isOwnerDrawn: Boolean;
|
||||||
isOwnerMeasure: Boolean;
|
isOwnerMeasure: Boolean;
|
||||||
|
isComboBoxEx: Boolean;
|
||||||
function acceptsFirstResponder: LCLObjCBoolean; override;
|
function acceptsFirstResponder: LCLObjCBoolean; override;
|
||||||
procedure dealloc; override;
|
procedure dealloc; override;
|
||||||
function lclGetCallback: ICommonCallback; override;
|
function lclGetCallback: ICommonCallback; override;
|
||||||
@ -491,7 +494,16 @@ begin
|
|||||||
mn := FOwner.itemAtIndex(Index);
|
mn := FOwner.itemAtIndex(Index);
|
||||||
if not Assigned(mn) then Exit;
|
if not Assigned(mn) then Exit;
|
||||||
|
|
||||||
astr := NSStringUtf8(S);
|
// for TComboBoxEx, the parameter S passed in is always emtpy,
|
||||||
|
// and NSPopUpButton always automatically sets the itemIndex according to
|
||||||
|
// the title, so a unique title needs to be set.
|
||||||
|
if not FOwner.isComboBoxEx then
|
||||||
|
astr := NSStringUtf8(S)
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
astr := NSStringUtf8(FId.ToString);
|
||||||
|
inc(FId);
|
||||||
|
end;
|
||||||
mn.setTitle(astr);
|
mn.setTitle(astr);
|
||||||
astr.release;
|
astr.release;
|
||||||
|
|
||||||
|
@ -1880,6 +1880,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
rocmb := NSView(TCocoaReadOnlyComboBox.alloc).lclInitWithCreateParams(AParams);
|
rocmb := NSView(TCocoaReadOnlyComboBox.alloc).lclInitWithCreateParams(AParams);
|
||||||
if not Assigned(rocmb) then Exit;
|
if not Assigned(rocmb) then Exit;
|
||||||
|
rocmb.isComboBoxEx:= not (AWinControl is TComboBox);
|
||||||
rocmb.list:=TCocoaReadOnlyComboBoxList.Create(rocmb);
|
rocmb.list:=TCocoaReadOnlyComboBoxList.Create(rocmb);
|
||||||
rocmb.setTarget(rocmb);
|
rocmb.setTarget(rocmb);
|
||||||
rocmb.setAction(objcselector('comboboxAction:'));
|
rocmb.setAction(objcselector('comboboxAction:'));
|
||||||
|
Loading…
Reference in New Issue
Block a user