Adding a Single Context Menu Entry
  • 21 Dec 2023
  • 1 Minute to read
  • Dark
    Light
  • PDF

Adding a Single Context Menu Entry

  • Dark
    Light
  • PDF

Article summary

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")
      }
    }
  }
}


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.