@samatawy/diagrams
    Preparing search index...

    Class ContextMenu

    Lightweight context menu that renders at fixed viewport coordinates.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    host: HTMLElement
    menuElement: HTMLElement | null = null

    Accessors

    Methods

    • Appends a labelled menu item that calls the given handler and closes the menu on click.

      Parameters

      • label: string

        Display text for the item.

      • onClick: () => void

        Callback invoked when the item is clicked.

      • options: { icon?: Element | null; active?: boolean; disabled?: boolean } = {}

        Optional icon element, active toggle state, and disabled flag.

      Returns HTMLElement

      The created menu item element.

    • Positions and displays the menu at the given viewport coordinates. Any previously open menu is closed first. Call this from open after populating items.

      Parameters

      • x: number

        Horizontal position in viewport pixels.

      • y: number

        Vertical position in viewport pixels.

      Returns void

    • Opens the context menu in response to a pointer event. Override in subclasses to populate items and call show. The base implementation does nothing.

      Parameters

      • _event: MouseEvent

        The pointer event that triggered the context menu.

      Returns void