diff --git a/lcl/comctrls.pp b/lcl/comctrls.pp index 500a60f35e..c835674ce1 100644 --- a/lcl/comctrls.pp +++ b/lcl/comctrls.pp @@ -1511,7 +1511,7 @@ type procedure Change(AItem: TListItem; AChange: Integer); virtual; procedure ColClick(AColumn: TListColumn); virtual; - procedure Delete(Item : TListItem); + procedure Delete(Item : TListItem); virtual; procedure DoDeletion(AItem: TListItem); virtual; procedure DoInsert(AItem: TListItem); virtual; procedure DoItemChecked(AItem: TListItem); @@ -1521,8 +1521,9 @@ type procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override; procedure DoEndEdit(AItem: TListItem; const AValue: String); virtual; + procedure Edit(AItem: TListItem); virtual; - procedure InsertItem(Item : TListItem); + procedure InsertItem(AItem : TListItem); virtual; procedure ImageChanged(Sender : TObject); procedure Loaded; override; procedure Notification(AComponent: TComponent; Operation: TOperation); override; diff --git a/lcl/include/customlistview.inc b/lcl/include/customlistview.inc index 269fc8c3f4..ff79f54bbe 100644 --- a/lcl/include/customlistview.inc +++ b/lcl/include/customlistview.inc @@ -587,7 +587,8 @@ end; {------------------------------------------------------------------------------} procedure TCustomListView.DoDeletion(AItem: TListItem); begin - if Assigned(FOnDeletion) then FOnDeletion(Self, AItem); + if not (csDestroying in ComponentState) and Assigned(FOnDeletion) then + FOnDeletion(Self, AItem); end; {------------------------------------------------------------------------------} @@ -595,7 +596,11 @@ end; {------------------------------------------------------------------------------} procedure TCustomListView.DoInsert(AItem: TListItem); begin - if Assigned(FOnInsert) then FOnInsert(Self, AItem); + if not (TMethod(@Self.InsertItem).Code = Pointer(@TCUstomListView.InsertItem)) then + //There is an override for InsertItem, so use that for Delphi compatibility. Issue #0038263 + InsertItem(AItem) + else + if Assigned(FOnInsert) then FOnInsert(Self, AItem); end; {------------------------------------------------------------------------------} @@ -671,6 +676,12 @@ begin AItem.Caption := S; end; +procedure TCustomListView.Edit(AItem: TListItem); +begin + if Assigned(AItem) then + DoEndEdit(AItem, AItem.Caption); +end; + {------------------------------------------------------------------------------} { TCustomListView ItemDeleted } {------------------------------------------------------------------------------} @@ -729,13 +740,15 @@ end; {------------------------------------------------------------------------------} procedure TCustomListView.Delete(Item : TListItem); begin + Item.Delete; end; {------------------------------------------------------------------------------} { TCustomListView InsertItem } {------------------------------------------------------------------------------} -procedure TCustomListView.InsertItem(Item : TListItem); +procedure TCustomListView.InsertItem(AItem : TListItem); begin + if Assigned(FOnInsert) then FOnInsert(Self, AItem); end; function TCustomListView.IntfCustomDraw(ATarget: TCustomDrawTarget; AStage: TCustomDrawStage; AItem, ASubItem: Integer; AState: TCustomDrawState; const ARect: PRect): TCustomDrawResult;