TextCursor GetCursorAtPosition( Vector2 position )

robot_2Generated
code_blocksInput

Description

The GetCursorAtPosition method in the Editor.TextEdit class is used to retrieve a TextCursor object that corresponds to a specific position within the text editor. This method is useful for determining the cursor's location based on a given 2D position, typically in screen or editor coordinates.

Usage

To use the GetCursorAtPosition method, you need to provide a Vector2 parameter that specifies the position within the text editor. The method will return a TextCursor object that represents the cursor at that position.

This method is particularly useful in scenarios where you need to interact with the text editor programmatically, such as implementing custom text selection or cursor movement logic based on user input or other events.

Example

// Example of using GetCursorAtPosition

// Assume 'textEdit' is an instance of Editor.TextEdit
Vector2 position = new Vector2(100, 50); // Example position
Editor.TextCursor cursor = textEdit.GetCursorAtPosition(position);

// Now 'cursor' holds the TextCursor at the specified position
// You can use 'cursor' to perform further operations, such as moving the cursor or selecting text.