Page 1 of 1

TSimpleGraph suggestion

PostPosted: July 10th, 2005, 7:50 pm
by vaccaro
Hello,

I did a simple and small change on TSimpleGraph.MouseUp event in order to allow create elements with one click. I hope this could be interesting to someone.

In the code below, "50" could be replaced by a "default size" property.

Best regards,

Guilherme Vaccaro.

Code: Select all
  ...
  else if CommandMode = cmInsertNode then
  begin
    { Start - Modified by Vaccaro - 10-07-2005 }
    {
    if (Button = mbLeft) and not (ssDouble in Shift) and
        not IsRectEmpty(SelectionRect)
    then
      InsertNode(@SelectionRect);
    }
    if (Button = mbLeft) and not (ssDouble in Shift) then
    begin
      if IsRectEmpty(SelectionRect) then
      begin
        if SnapToGrid and not (ssCtrl in Shift) then
          StopPoint := Point((StartPoint.X + 50) div GridSize * GridSize, (StartPoint.Y + 50) div GridSize * GridSize)
        else
          StopPoint := Point(StartPoint.X + 50, StartPoint.Y + 50);
        SelectionRect := MakeRect(StartPoint, StopPoint);
      end;
      InsertNode(@SelectionRect);
    end;
    { Stop - Modified by Vaccaro - 10-07-2005 }
    CommandMode := cmEdit;
    if ssShift in Shift then
      CommandMode := cmInsertNode;
  end
  ....

Thanks

PostPosted: August 22nd, 2005, 8:15 am
by perahi
This was very interresting to me! I have implemented it into my TSimpleGraph.

Thank you very much!

PAH