Point.Clone

From Xojo Documentation

Method

Point.Clone() As Point

New in 2019r2

Supported for all project types and targets.

Creates a duplicate of the point.

Sample Code

This example is in the MouseDrag event of a Rect. The object is being cloned as the way to update its position.

// Update our mouse position.
mousePosition = New Point(x, y)

// If we're actually dragging something, move the rect.
// We update the rect's origin with a CLONE of the mouse position,
// because MousePosition is an instance of the Point class.
// Without the clone, when we call the offset function, we'll also update
// the MousePosition property, since both DraggingRect.Origin and MousePosition
// would point to the same variable.

// The offset function shifts the rect. Positive for right/down,
// negative for left/up.

If draggingrect <> Nil Then
DraggingRect.Origin = Mouseposition.Clone
DraggingRect.Offset(MouseOffset.x, MouseOffset.y)
End If

// refresh, without erasing the background
Me.Invalidate(False)