Manages cursor appearance and behavior for the CAD editor.

This class creates and applies custom cursors to HTML elements, providing visual feedback for different CAD operations. It supports both built-in browser cursors and custom SVG-based cursors.

The cursor manager maintains a cache of cursor definitions to avoid recreating them repeatedly, improving performance.

This class is for internal use by the editor system

const cursorManager = new AcEdCursorManager();
const canvas = document.getElementById('canvas') as HTMLCanvasElement;

// Set crosshair cursor
cursorManager.setCursor(AcEdCorsorType.Crosshair, canvas);

// Set grab cursor for panning
cursorManager.setCursor(AcEdCorsorType.Grab, canvas);

Constructors

Methods

  • Encodes an SVG string into a CSS cursor URL.

    This method converts SVG markup into a data URI that can be used as a CSS cursor value, with specified hotspot coordinates.

    Parameters

    • svgString: string

      The SVG markup as a string

    • xOffset: number

      X coordinate of the cursor hotspot

    • yOffset: number

      Y coordinate of the cursor hotspot

    Returns string

    CSS cursor string in url() format

    const svgCursor = '<svg width="20" height="20">...</svg>';
    const cursorUrl = cursorManager.encodeSvgToCursor(svgCursor, 10, 10);
    element.style.cursor = cursorUrl;
  • Sets the cursor for the specified HTML element.

    Applies the appropriate cursor style based on the cursor type. For built-in cursor types, uses CSS cursor values. For custom cursor types, uses cached SVG-based cursor definitions.

    Parameters

    • cursorType: AcEdCorsorType

      The type of cursor to set

    • element: HTMLElement

      The HTML element to apply the cursor to

    Returns void

    const canvas = document.getElementById('canvas') as HTMLCanvasElement;
    cursorManager.setCursor(AcEdCorsorType.Crosshair, canvas);