TextEdit.CharacterPosition

From Xojo Documentation

Method

TextEdit.CharacterPosition(LineNumber as Integer) As Integer

New in 2019r2

Supported for all project types and targets.

Returns as an Integer the character position in the control of the first character on the LineNumber line.


Method

TextEdit.CharacterPosition(X as Integer, Y as Integer) As Integer

New in 2019r2

Supported for all project types and targets.

Returns as an Integer the character position for pixel coordinates X, Y relative to the control.

Notes

Characters are numbered consecutively from the start until the end of the control. The first character is numbered 1. The first line is numbered zero.

Example

This example gets the character position of the first character of the second line.

Var i As Integer
i = TextArea1.CharacterPosition(1)

This example is in the MouseDown event of the control. The event passes in the X,Y coordinates of the MouseDown event. The example gets the position of the character at the passed coordinates.

Var i As Integer
i = Me.CharacterPosition(x, y)
MessageBox(i.ToString)
Return True