static bool LockCursorToCanvas( Widget canvas, int margin )

book_4_sparkGenerated
code_blocksInput

Description

The LockCursorToCanvas method is a static utility function provided by the Editor.SceneEditorExtensions class. It is used to lock the cursor within the boundaries of a specified canvas widget in the editor environment. This can be particularly useful when implementing custom editor tools or interfaces that require precise cursor control within a defined area.

Usage

To use the LockCursorToCanvas method, you need to pass an instance of Editor.Widget representing the canvas you want to lock the cursor to, and an integer value specifying the margin around the canvas within which the cursor can move. The method returns a boolean indicating whether the cursor was successfully locked to the canvas.

Example

// Example usage of LockCursorToCanvas
Editor.Widget myCanvas = GetMyCanvas(); // Assume this method retrieves your canvas widget
int margin = 10; // Set a margin of 10 pixels

bool isLocked = Editor.SceneEditorExtensions.LockCursorToCanvas(myCanvas, margin);

if (isLocked)
{
    // Cursor is successfully locked to the canvas
    // Perform additional operations if needed
}
else
{
    // Handle the case where the cursor could not be locked
}