mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-11 19:28:58 +02:00
IDE: Allow adding CollectionItems again via OI tree's context menu. Issue #38239.
git-svn-id: trunk@64263 -
This commit is contained in:
parent
573d742f51
commit
9c3791702a
73
ide/main.pp
73
ide/main.pp
@ -13306,49 +13306,46 @@ var
|
||||
ComponentClasses: TClassList;
|
||||
begin
|
||||
//DebugLn('Hint: (lazarus) TMainIDE.PropHookPersistentAdded A ',dbgsName(APersistent));
|
||||
Assert(APersistent is TComponent, 'TMainIDE.PropHookPersistentAdded: Not a TComponent.');
|
||||
//if APersistent is TComponent then
|
||||
//begin
|
||||
AComponent:=TComponent(APersistent);
|
||||
if (IDEComponentPalette.FindRegComponent(AComponent.ClassType)=nil)
|
||||
and (Project1.UnitWithComponentClass(TComponentClass(AComponent.ClassType))=nil) then
|
||||
if APersistent is TComponent then
|
||||
begin
|
||||
DebugLn('Error: (lazarus) TMainIDE.PropHookPersistentAdded ',
|
||||
AComponent.ClassName, ' not registered');
|
||||
exit;
|
||||
end;
|
||||
//debugln('TMainIDE.PropHookPersistentAdded B ',AComponent.Name,':',AComponent.ClassName);
|
||||
// set component into design mode
|
||||
SetDesigning(AComponent,true);
|
||||
//debugln('TMainIDE.PropHookPersistentAdded C ',AComponent.Name,':',AComponent.ClassName);
|
||||
// add to source
|
||||
FComponentAddedDesigner:=FindRootDesigner(AComponent) as TDesigner;
|
||||
if FComponentAddedDesigner<>nil then
|
||||
begin
|
||||
ActiveSrcEdit:=nil;
|
||||
if BeginCodeTool(FComponentAddedDesigner,ActiveSrcEdit,FComponentAddedUnit,
|
||||
[ctfSwitchToFormSource]) then
|
||||
AComponent:=TComponent(APersistent);
|
||||
if (IDEComponentPalette.FindRegComponent(AComponent.ClassType)=nil)
|
||||
and (Project1.UnitWithComponentClass(TComponentClass(AComponent.ClassType))=nil) then
|
||||
begin
|
||||
// add needed package to required packages
|
||||
if AComponent<>nil then
|
||||
begin
|
||||
ComponentClasses:=TClassList.Create;
|
||||
try
|
||||
ComponentClasses.Add(AComponent.ClassType);
|
||||
PkgBoss.AddUnitDepsForCompClasses(FComponentAddedUnit.Filename,ComponentClasses,true);
|
||||
finally
|
||||
ComponentClasses.Free;
|
||||
end;
|
||||
end;
|
||||
// Note: Source editor will be updated with added components later on Idle
|
||||
// using FComponentAddedDesigner and FComponentAddedUnit.
|
||||
end
|
||||
else begin
|
||||
FComponentAddedDesigner:= Nil;
|
||||
DebugLn('Error: (lazarus) TMainIDE.PropHookPersistentAdded ',
|
||||
AComponent.ClassName, ' not registered');
|
||||
exit;
|
||||
end;
|
||||
//debugln('TMainIDE.PropHookPersistentAdded B ',AComponent.Name,':',AComponent.ClassName);
|
||||
// set component into design mode
|
||||
SetDesigning(AComponent,true);
|
||||
//debugln('TMainIDE.PropHookPersistentAdded C ',AComponent.Name,':',AComponent.ClassName);
|
||||
// add to source
|
||||
FComponentAddedDesigner:=FindRootDesigner(AComponent) as TDesigner;
|
||||
if FComponentAddedDesigner<>nil then
|
||||
begin
|
||||
ActiveSrcEdit:=nil;
|
||||
if BeginCodeTool(FComponentAddedDesigner,ActiveSrcEdit,FComponentAddedUnit,
|
||||
[ctfSwitchToFormSource]) then
|
||||
begin
|
||||
// add needed package to required packages
|
||||
if AComponent<>nil then
|
||||
begin
|
||||
ComponentClasses:=TClassList.Create;
|
||||
try
|
||||
ComponentClasses.Add(AComponent.ClassType);
|
||||
PkgBoss.AddUnitDepsForCompClasses(FComponentAddedUnit.Filename,ComponentClasses,true);
|
||||
finally
|
||||
ComponentClasses.Free;
|
||||
end;
|
||||
end;
|
||||
// Note: Source editor will be updated with added components later on Idle
|
||||
// using FComponentAddedDesigner and FComponentAddedUnit.
|
||||
end
|
||||
else
|
||||
FComponentAddedDesigner:=Nil;
|
||||
end;
|
||||
end;
|
||||
//end;
|
||||
// select persistent
|
||||
if Select then
|
||||
TheControlSelection.AssignPersistent(APersistent);
|
||||
|
Loading…
Reference in New Issue
Block a user