<div class="meta" robots="noindex">

</div>

Class

# Realbasic.Point

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

<div class="warning">

<div class="title">

Warning

</div>

This item was deprecated in version 2019r2. Please use `Point</api/graphics/point>` as a replacement.

</div>

## Description

An object used to represent and work with a given point in the coordinate system.

## Properties

<div class="rst-class">

table-centered_columns_3_and_4

</div>

| Name                   | Type                               | Read-Only | Shared |
|------------------------|------------------------------------|-----------|--------|
| `X<realbasic.point.x>` | `Integer</api/data_types/integer>` |           |        |
| `Y<realbasic.point.y>` | `Integer</api/data_types/integer>` |           |        |

## Methods

<div class="rst-class">

table-centered_column_4

</div>

| Name                                        | Parameters                                                                                 | Returns                          | Shared |
|---------------------------------------------|--------------------------------------------------------------------------------------------|----------------------------------|--------|
| `Clone<realbasic.point.clone>`              |                                                                                            | Realbasic.Point                  |        |
| `Constructor<realbasic.point.constructor0>` |                                                                                            |                                  |        |
| `Constructor<realbasic.point.constructor1>` | X As `Integer</api/data_types/integer>`, Y As `Integer</api/data_types/integer>`           |                                  |        |
| `Distance<realbasic.point.distance>`        | Other As Realbasic.Point                                                                   | `Double</api/data_types/double>` |        |
| `Offset<realbasic.point.offset>`            | DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/integer>` |                                  |        |

## Property descriptions

<div id="realbasic.point.x">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Point.X

**X** As `Integer</api/data_types/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.

``` xojo
' 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
```

<div id="realbasic.point.y">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Point.Y

**Y** As `Integer</api/data_types/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.

``` xojo
' 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

<div id="realbasic.point.clone">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Point.Clone

**Clone** As Realbasic.Point

Creates a duplicate of the point.

This example is in the MouseDrag event of a `Rect</api/graphics/rect>`. The object is being cloned as the way to update its position.

``` xojo
' 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)
```

<div id="realbasic.point.constructor0">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Point.Constructor

**Constructor**

<div class="note">

<div class="title">

Note

</div>

`Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.

</div>

Creates a point at position (0, 0).

<div id="realbasic.point.constructor1">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Point.Constructor

**Constructor**(X as `Integer</api/data_types/integer>`, Y as `Integer</api/data_types/integer>`)

<div class="note">

<div class="title">

Note

</div>

`Constructors</api/language/constructor>` are special methods called when you create an object with the `New</api/language/new>` keyword and pass in the parameters above.

</div>

Creates a basic point with the passed coordinates.

Create a point at 100, 50:

``` xojo
Dim p As New Realbasic.Point(100, 50)
```

<div id="realbasic.point.distance">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Point.Distance

**Distance**(Other As Realbasic.Point) As `Double</api/data_types/double>`

Calculates the distance between the point and the passed point.

``` xojo
Dim thePoint As Realbasic.Point = DraggingRect.Origin
Dim d As Double = thePoint.Distance(RectTwo.Origin)
```

<div id="realbasic.point.offset">

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

</div>

<div class="rst-class">

forsearch

</div>

Realbasic.Point.Offset

**Offset**(DeltaX As `Integer</api/data_types/integer>`, DeltaY As `Integer</api/data_types/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</api/graphics/rect>`. The object is being cloned as the way to update its position. MouseOffset is a <span class="title-ref">Realbasic.Point</span> property of the window.

``` xojo
' 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</api/deprecated/canvas>` control; `Window</api/deprecated/window>`, `DesktopContainer</api/user_interface/desktop/desktopcontainer>`, `Rect</api/graphics/rect>`, `Size</api/graphics/size>` classes.
