mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 22:40:27 +02:00
fixed adding a control to a form by double clicking while a non-control was selected (issue #1856)
git-svn-id: trunk@9048 -
This commit is contained in:
parent
de888c86b3
commit
fd3b592a8d
@ -1837,18 +1837,22 @@ begin
|
|||||||
// find selected component
|
// find selected component
|
||||||
if (FSelection = nil) or (FSelection.Count <= 0) then Exit;
|
if (FSelection = nil) or (FSelection.Count <= 0) then Exit;
|
||||||
NewParent:=TComponent(FSelection[0]);
|
NewParent:=TComponent(FSelection[0]);
|
||||||
|
//Debugln('TCustomFormEditor.GetDefaultComponentParent A:', DbgSName(NewParent));
|
||||||
if not (NewParent is TComponent) then exit;
|
if not (NewParent is TComponent) then exit;
|
||||||
if TypeClass<>nil then begin
|
if TypeClass<>nil then begin
|
||||||
if TypeClass.InheritsFrom(TControl) then begin
|
if TypeClass.InheritsFrom(TControl) and (NewParent is TControl) then begin
|
||||||
// New TypeClass is a TControl => use only a TWinControl as parent
|
// New TypeClass is a TControl and selected component is TControl =>
|
||||||
|
// use only a TWinControl as parent
|
||||||
while (NewParent<>nil) do begin
|
while (NewParent<>nil) do begin
|
||||||
if (NewParent is TWinControl)
|
if (NewParent is TWinControl)
|
||||||
and (csAcceptsControls in TWinControl(NewParent).ControlStyle) then
|
and (csAcceptsControls in TWinControl(NewParent).ControlStyle) then
|
||||||
break;
|
break;
|
||||||
NewParent:=TControl(NewParent).Parent;
|
NewParent:=TControl(NewParent).Parent;
|
||||||
|
//Debugln('TCustomFormEditor.GetDefaultComponentParent B:', DbgSName(NewParent));
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// New TypeClass is not a TControl => Root component as parent
|
// New TypeClass or selected component is not a TControl =>
|
||||||
|
// use Root component as parent
|
||||||
Root:=GetLookupRootForComponent(NewParent);
|
Root:=GetLookupRootForComponent(NewParent);
|
||||||
if Root is TComponent then
|
if Root is TComponent then
|
||||||
NewParent:=TComponent(Root);
|
NewParent:=TComponent(Root);
|
||||||
|
Loading…
Reference in New Issue
Block a user