TermEdit.getCursorOffset

Syntax

getCursorOffset();

Description

The getCursorOffset method returns the cursor position relative to the upper left corner of the component.

Example

To execute the example, create the TermEdit component named termEdit.

In the BODY tag add a button named get selected term which, when pressed, performs the function getPosition(), and a row that should display the output of this function:

<!--Button-->

<input type="button" value="get cursor position" onclick="getPosition();" style="vertical-align: top;" />

<!--Row-->

<span id="getterCaret"></span>

Add a function to the Javascript code:

function getPosition() {

    var pos = termEdit.getCursorOffset();

    var pos1 = termEdit.getCursorPosition();

    if (pos != null) {

        document.getElementById("getterCaret").innerHTML = "X: " + pos.X + " Y: " + pos.Y + " Row: " + pos1.rowIndex + " Column: " + pos1.columnIndex

    }

}

After executing the example, on pressing the get cursor position button the page displays a message about the current cursor position relative to the upper left corner of the component ( X and Y axis), as well as indices of the column and the row that contain the cursor.

See also:

TermEdit