TMyCompEditor = class(TComponentEditor)
private
FPropInfo: PPropInfo;
FPropEdit: IProperty;
procedure GetPropProc(const PropEdit: IProperty);
public
constructor Create(AComponent: TComponent; ADesigner: IDesigner); override;
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
procedure Register;
begin
RegisterComponents('YzExamples', [TMyComp]);
RegisterComponentEditor(TMyComp, TMyCompEditor)
end;
constructor TMyCompEditor.Create(AComponent: TComponent; ADesigner: IDesigner);
begin
inherited;
FPropInfo := GetPropInfo(GetComponent.ClassInfo, 'MyItems', [tkClass])
end;
procedure TMyCompEditor.ExecuteVerb(Index: Integer);
var
Selections: TDesignerSelections;
begin
if Index = GetVerbCount - 1 then
begin
if (FPropEdit = nil) and (FPropInfo <> nil) then
begin
Selections := TDesignerSelections.Create;
try
Designer.GetSelections(Selections);
GetComponentProperties(Selections, [tkClass], Designer, GetPropProc)
finally
Selections.Free
end
end;
if FPropEdit <> nil then
FPropEdit.Edit
end
else
inherited
end;
procedure TMyCompEditor.GetPropProc(const PropEdit: IProperty);
begin
if PropEdit.GetPropInfo = FPropInfo then
FPropEdit := PropEdit
end;
function TMyCompEditor.GetVerb(Index: Integer): string;
begin
if Index = GetVerbCount - 1 then
Result := 'MyItems Editor...'
else
Result := inherited GetVerb(Index)
end;
function TMyCompEditor.GetVerbCount: Integer;
begin
Result := inherited GetVerbCount + 1
end;