I've never been in a situation that needed it, and this is the first time I try to have a TCollection
as TCollectionItem
of another TCollection
.
It all compiles fine, but there is no reaction when the three dots behind the TCollectionItem
's TCollection
property are clicked, ie. the dialog with the list of that sub-TCollection
does not appear.
I was under the impression that, since no fancy property editors should be necessary (the sub-TCollection
only carries items that have a string
and a single
property), the IDE would pretty much handle it automatically.
Apparently that's not the case, or I'm overseeing the obvious, which is a chronic affliction.
The implementation (run-time) unit has this:
type
TBitmapItemTag = class(TCollectionItem)
private
FTagName: string;
FTagFloat: Single;
published
property TagName: string read FTagName write FTagName;
property TagFloat: Single read FTagFloat write FTagFloat;
end;
TBitmapItemTags = class(TOwnedCollection)
end;
TBitmapItem = class(TCollectionItem)
private
FBitmap: TBitmap;
FBitmapItemTags: TBitmapItemTags;
public
constructor Create(Collection: TCollection); override;
destructor Destroy; override;
published
property Bitmap: TBitmap read FBitmap write FBitmap;
property Tags: TBitmapItemTags read FBitmapItemTags write FBitmapItemTags;
end;
TBitmaps = class(TCollection)
end;
TBitmapCollection = class(TComponent)
private
FBitmaps: TBitmaps;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
published
property Bitmaps: TBitmaps read FBitmaps write FBitmaps;
end;
implementation
{ TBitmapItem }
constructor TBitmapItem.Create(Collection: TCollection);
begin
inherited Create(Collection);
FBitmap := TBitmap.Create(0, 0);
FBitmapItemTags := TBitmapItemTags.Create(Self,TBitmapItemTag);
end;
destructor TBitmapItem.Destroy;
begin
FBitmap.Free;
FBitmapItemTags.Free;
inherited;
end;
{ TBitmapCollection }
constructor TBitmapCollection.Create(AOwner: TComponent);
begin
inherited;
FBitmaps := TBitmaps.Create(TBitmapItem);
end;
destructor TBitmapCollection.Destroy;
begin
FBitmaps.Free;
inherited;
end;
The Register
procedure is implemented in the design-time unit and just calls the RegisterComponents
procedure. And holds some lazy RegisterPropertyEditor
tries that were to no avail.
If anyone can point me to the shortest path in order for the IDE to recognize the TBitmapItemTag TCollectionItem
, I'd be grateful.