MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.
procedure TForm1.ShapeMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin // i now make a difference between selecting and dragging a shape // this make it possible to keep a selection and that is usefull for the speedbutton function FSelectedShape := TShape(Sender); // Might be usefull for other treatments if Assigned(FSelectedShape) then begin //ShapeMenu: TPopupMenu; if ssRight in Shift Then PopupMenu1.Popup(Mouse.CursorPos.X,Mouse.CursorPos.Y); if ssLeft in Shift then begin // set the last clicked shape with right button // get its start position relative to position of mouse when the click occurred _Pos.X := FSelectedShape.Left-Mouse.CursorPos.X; _Pos.Y := FSelectedShape.Top-Mouse.CursorPos.Y; FDragShape := FSelectedShape; end; end; end; procedure TForm1.ShapeMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin // only dragging with left mouse button if Not (ssLeft in Shift) then FDragShape := nil; if Not Assigned(FDragShape) then Exit; // Don't use X & Y directly as they are relative to the object, which is moving FDragShape.Left := _Pos.X + Mouse.CursorPos.X; FDragShape.Top := _Pos.Y + Mouse.CursorPos.Y; FSelectedShapelabel.Left:= _Pos.X + Mouse.CursorPos.X; FSelectedShapelabel.Top := _Pos.Y + Mouse.CursorPos.Y - 12; end; procedure TForm1.ShapeMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin //finish the drag FDragShape := nil; end;
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.