mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 17:01:35 +02:00
IDE, IDEIntf: fixed componentreeview dragover check
git-svn-id: trunk@42713 -
This commit is contained in:
parent
c50737c1d3
commit
e140abe386
@ -381,6 +381,7 @@ var
|
||||
AcceptControl, AcceptContainer: Boolean;
|
||||
InsertType: TTreeViewInsertMarkType;
|
||||
ParentNode: TTreeNode;
|
||||
aLookupRoot: TPersistent;
|
||||
begin
|
||||
//debugln('TComponentTreeView.DragOver START ',dbgs(Accept));
|
||||
|
||||
@ -390,6 +391,11 @@ begin
|
||||
GetComponentInsertMarkAt(X, Y, Node, InsertType);
|
||||
SetInsertMark(Node, InsertType);
|
||||
|
||||
if PropertyEditorHook<>nil then
|
||||
aLookupRoot := PropertyEditorHook.LookupRoot
|
||||
else
|
||||
aLookupRoot := nil;
|
||||
|
||||
// check new parent
|
||||
ParentNode := Node;
|
||||
if InsertType in [tvimAsNextSibling, tvimAsPrevSibling] then
|
||||
@ -399,14 +405,9 @@ begin
|
||||
AnObject := TObject(ParentNode.Data);
|
||||
if (AnObject is TWinControl) then
|
||||
begin
|
||||
if (csAcceptsControls in AControl.ControlStyle) and
|
||||
// Because of TWriter, you can not put a control onto an csInline, csAncestor controls (e.g. on a frame or it child).
|
||||
([csInline, csAncestor] * AControl.ComponentState = []) and
|
||||
( // TReader/TWriter only supports this
|
||||
(AControl.Owner = nil) or // root
|
||||
(AControl.Owner.Owner = nil) // child of a root
|
||||
) then
|
||||
begin
|
||||
if ControlAcceptsStreamableChildComponent(TWinControl(AControl),
|
||||
TComponentClass(AnObject.ClassType),aLookupRoot)
|
||||
then begin
|
||||
AContainer := TPersistent(AnObject);
|
||||
//DebugLn(['TComponentTreeView.DragOver AContainer=',DbgSName(AContainer)]);
|
||||
AcceptContainer := True;
|
||||
|
@ -1563,6 +1563,8 @@ function ClassTypeInfo(Value: TClass): PTypeInfo;
|
||||
function GetClassUnitName(Value: TClass): string;
|
||||
procedure CreateComponentEvent(AComponent: TComponent; const EventName: string);
|
||||
function ClassNameToComponentName(const AClassName: string): string;
|
||||
function ControlAcceptsStreamableChildComponent(aControl: TWinControl;
|
||||
aComponentClass: TComponentClass; aLookupRoot: TPersistent): boolean;
|
||||
|
||||
procedure LazSetMethodProp(Instance : TObject;PropInfo : PPropInfo; Value : TMethod);
|
||||
procedure WritePublishedProperties(Instance: TPersistent);
|
||||
@ -1679,7 +1681,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
Procedure LazSetMethodProp(Instance : TObject;PropInfo : PPropInfo; Value : TMethod);
|
||||
procedure LazSetMethodProp(Instance: TObject; PropInfo: PPropInfo;
|
||||
Value: TMethod);
|
||||
type
|
||||
PMethod = ^TMethod;
|
||||
TSetMethodProcIndex=procedure(index:longint;p:TMethod) of object;
|
||||
@ -6371,7 +6374,27 @@ begin
|
||||
System.Delete(Result,1,1);
|
||||
end;
|
||||
|
||||
Function ClassTypeInfo(Value: TClass): PTypeInfo;
|
||||
function ControlAcceptsStreamableChildComponent(aControl: TWinControl;
|
||||
aComponentClass: TComponentClass; aLookupRoot: TPersistent): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
if not (csAcceptsControls in aControl.ControlStyle) then exit;
|
||||
|
||||
// Because of TWriter, you can not put a control onto an
|
||||
// csInline,csAncestor control (e.g. on a frame).
|
||||
if ([csInline,csAncestor]*aControl.ComponentState<>[]) then exit;
|
||||
|
||||
if aComponentClass.InheritsFrom(TControl)
|
||||
and not aControl.CheckChildClassAllowed(aComponentClass, False) then exit;
|
||||
|
||||
// TWriter only supports children of LookupRoot and LookupRoot.Components
|
||||
if (aControl.Owner <> aLookupRoot) and (aControl <> aLookupRoot) then exit;
|
||||
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
|
||||
function ClassTypeInfo(Value: TClass): PTypeInfo;
|
||||
begin
|
||||
Result := PTypeInfo(Value.ClassInfo);
|
||||
end;
|
||||
|
@ -1881,15 +1881,11 @@ var
|
||||
else
|
||||
NewParentControl := WinControlAtPos(MouseUpPos.X, MouseUpPos.Y, true, true);
|
||||
|
||||
while (NewParentControl <> nil) and
|
||||
((not (csAcceptsControls in NewParentControl.ControlStyle)) or
|
||||
(NewComponentClass.InheritsFrom(TControl) and not NewParentControl.CheckChildClassAllowed(NewComponentClass, False)) or
|
||||
(csInline in NewParentControl.ComponentState) or // Because of TWriter, you can not put a control onto an csInline control (e.g. on a frame).
|
||||
((NewParentControl.Owner <> FLookupRoot) and
|
||||
(NewParentControl <> FLookupRoot))) do
|
||||
begin
|
||||
while (NewParentControl <> nil)
|
||||
and not ControlAcceptsStreamableChildComponent(NewParentControl,
|
||||
NewComponentClass,FLookupRoot)
|
||||
do
|
||||
NewParentControl := NewParentControl.Parent;
|
||||
end;
|
||||
NewParent := NewParentControl;
|
||||
end;
|
||||
if not Assigned(NewParent) then exit;
|
||||
|
Loading…
Reference in New Issue
Block a user