Adding a Single Context Menu Entry

To include one context menu entry, the override method should return a ContextMenuEntry object. The properties for a valid ContextMenuEntry are:

name

The text that appears in the menu

icon

An icon ligature name that appears next to the name

callback

The function that is triggered when a user clicks or presses the entry

Run the following to add a single context menu entry:

// SampleContextMenuEntryLayer.ts
import {
  ContextMenuEntryInterface, CustomLayer,
  MouseEventCoordinatesInterface
} from "@navvis/ivion";

export class SampleContextMenuEntryLayer extends CustomLayer
{
  public onContextMenu(pos: MouseEventCoordinatesInterface): ContextMenuEntryInterface
  {
    //return the ContextMenuEntryInterface
    return {
      name: "Go to Navvis",
      icon: "fa-globe",
      callback: () =>
      {
        window.open("https://www.navvis.com")
      }
    }
  }
}