- Code: Select all
procedure TSimpleGraph.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
Pt: TPoint;
NewObject: TGraphObject;
begin
if not Focused then SetFocus;
inherited MouseDown(Button, Shift, X, Y);
Pt := ClientToGraph(X, Y);
CheckObjectAtCursor(Pt);
case CommandMode of
cmInsertNode, cmInsertLink:
if Assigned(DragSource) then
DragSource.MouseDown(Button, Shift, Pt)
else if (Button = mbLeft) and not (ssDouble in Shift) then
begin
NewObject := nil;
case CommandMode of
cmInsertNode:
NewObject := InsertObjectByMouse(Pt, DefaultNodeClass, SnapToGrid xor (ssCtrl in Shift));
cmInsertLink:
NewObject := InsertObjectByMouse(Pt, DefaultLinkClass, SnapToGrid xor (ssCtrl in Shift));
end;
showmessage('MouseDown Hier1');
if Assigned(NewObject) then
begin
NewObject.Selected := True;
NewObject.MouseDown(Button, Shift, Pt);
showmessage('MouseDown Hier2');
if DragSource <> NewObject then
begin
showmessage('MouseDown Hier3');
CommandMode := cmEdit;
showmessage('MouseDown Hier4');
ObjectChanged(NewObject, [gcData]);
end
else
CursorPos := Pt;
RenewObjectAtCursor(NewObject);
end;
end;
cmPan:
if (Button = mbLeft) and not (ssDouble in SHift) then
begin
fDragSourcePt.X := X;
fDragSourcePt.Y := Y;
Screen.Cursor := crHandGrab
end;
else
if Assigned(ObjectAtCursor) and (CommandMode <> cmViewOnly) and
(goSelectable in ObjectAtCursor.Options)
then
ObjectAtCursor.MouseDown(Button, Shift, Pt)
else if ((Button = mbLeft)
and not (ssDouble in Shift)
and (CommandMode <> cmViewOnly))
or
((Button = mbLeft)
and not (ssDouble in Shift)
and (ssAlt in Shift)
and (CommandMode = cmViewOnly))
then {HPW commandmode check}
begin
fDragSourcePt := Pt;
fDragTargetPt := Pt;
MarkedArea := MakeRect(fDragSourcePt, fDragTargetPt);
Screen.Cursor := crCross;
end;
end;
end;
- Code: Select all
procedure TSimpleGraph.SetCommandMode(Value: TGraphCommandMode);
begin
if CommandMode <> Value then
begin
if Assigned(DragSource) then
begin
showmessage('Hier1');
DragSource.EndDrag(False);
showmessage('Hier2');
end;
fCommandMode := Value;
if not (CommandMode in [cmPan, cmEdit]) then
SelectedObjects.Clear;
CalcAutoRange;
DoCommandModeChange;
end;
end;
When I try to insert a link-line in EditMode starting at a empty area, I reach:
showmessage('MouseDown Hier3');
but only in delphi5 and not in delphi7!
In delphi 5 it reaches then SetCommandMode with:
showmessage('Hier1');
and throw an access vilation in:
DragSource.EndDrag(False);
Any ideas whats going wrong in D5 and how to workaround?