I would like to restrict lines on the drawing all to be connected to linkpoints, and after that also restrict which linkpoints can be joined.
I started to code the OnAcceptLink event handler, but I discovered that this event is never fired if I draw a line in the middle of nowhere. without connection any blocks.
Use property RequiresConnections to prevent lines to be inserted without being connected to some link point. Then continue using OnAcceptLink to filter which link points are accepted or not.
Problem is when the OnInsertLink is called the line is already inserted. You must set Requiresconnections before the line is inserted. Here is one way of doing that:
type
TMyDiagramLine = class(TDiagramLine)
public
constructor Create(AOwner: TComponent); override;
end;
constructor TMyDiagramLine.Create(AOwner: TComponent);
begin
inherited;
RequiresConnections := true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
// Replace TDiagramLine type by my own TMyDiagramLine
RegDControlList.FindByID('TDiagramLine').DControlClass := MyDiagramLine;
end;