Realbasic.Rect.Clone

From Real Software Documentation

Jump to: navigation, search
Method
Realbasic.Rect.Clone ( )

Creates a duplicate of the Rect.

Example

This is the MouseDrag event handler of the Canvas in the Rects example in the Examples folder that ships with Real Studio. Clone is used to update the position of the rect in the drag.

/ Update our mouse position.
mouseposition = New Realbasic.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 REALbasic.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 simply 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.Refresh(False)
Personal tools