Class
Realbasic.Point
Warning
This item was deprecated in version 2019r2. Please use Point as a replacement.
Description
An object used to represent and work with a given point in the coordinate system.
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
Realbasic.Point |
|||
Other As Realbasic.Point |
|||
Property descriptions
Realbasic.Point.X
X As Integer
The horizontal coordinate of the point.
This code is in the MouseDown event handler. The new mouseposition is passed as the X,Y coordinates and mouseoffset is a property of the window.
' Update our mouse position.
mouseposition = New Realbasic.Point(x, y)
' Now we determine which rect our cursor is in
' and save the offset (how far the cursor is inside the rect)
' so when the user moves the cursor, the rect
' won't jump around.
If rectone.Contains(mouseposition) Then
mouseoffset.X = rectone.Origin.X - mouseposition.X
mouseoffset.Y = rectone.Origin.Y - mouseposition.X
draggingrect = rectone
ElseIf recttwo.Contains(mouseposition) Then
mouseoffset.X = recttwo.Origin.X - mouseposition.X
mouseoffset.Y = recttwo.Origin.Y - mouseposition.Y
draggingrect = recttwo
Else
mouseoffset.X = 0
mouseoffset.Y = 0
draggingrect = Nil
End If
' refresh, without erasing the background
Me.Invalidate(False)
Return True
Realbasic.Point.Y
Y As Integer
The horizontal coordinate of the point.
This code is in the MouseDown event handler. The new mouseposition is passed as the X,Y coordinates and mouseoffset is a property of the window.
' Update our mouse position.
mouseposition = New Realbasic.Point(x, y)
' Now we determine which rect our cursor is in
' and save the offset (how far the cursor is inside the rect)
' so when the user moves the cursor, the rect
' won't jump around.
If rectone.Contains(mouseposition) Then
mouseoffset.X = rectone.Origin.X - mouseposition.X
mouseoffset.Y = rectone.Origin.Y - mouseposition.X
draggingrect = rectone
ElseIf recttwo.Contains(mouseposition) Then
mouseoffset.X = recttwo.Origin.X - mouseposition.X
mouseoffset.Y = recttwo.Origin.Y - mouseposition.Y
draggingrect = recttwo
Else
mouseoffset.X = 0
mouseoffset.Y = 0
draggingrect = Nil
End If
' refresh, without erasing the background
Me.Invalidate(False)
Return True
Method descriptions
Realbasic.Point.Clone
Clone As Realbasic.Point
Creates a duplicate of the point.
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 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 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)
Realbasic.Point.Constructor
Constructor
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a point at position (0, 0).
Realbasic.Point.Constructor
Constructor(X as Integer, Y as Integer)
Note
Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.
Creates a basic point with the passed coordinates.
Create a point at 100, 50:
Dim p As New Realbasic.Point(100, 50)
Realbasic.Point.Distance
Distance(Other As Realbasic.Point) As Double
Calculates the distance between the point and the passed point.
Dim thePoint As Realbasic.Point = DraggingRect.Origin
Dim d As Double = thePoint.Distance(RectTwo.Origin)
Realbasic.Point.Offset
Offset(DeltaX As Integer, DeltaY As Integer)
Moves the point the given number of pixels. Positive numbers move the point down or to the right, negative move it up or to the left.
This example is in the MouseDrag event of a Rect. The object is being cloned as the way to update its position. MouseOffset is a Realbasic.Point property of the window.
' 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 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)
Compatibility
All project types on all supported operating systems.
See also
Object parent class; Canvas control; Window, DesktopContainer, Rect, Size classes.