Creating the popup menu for custom canvas objects

Hi. I’m creating a plugin that adds custom objects to the canvas (beyond nodes and edges). When these custom objects are selected, I want to show a popup menu in the same style and position as the native node/edge selection popup (the pop-up menu when left-clicking a node or edge). Can anyone point me to:

  • How to create and show a popup menu programmatically
  • Event listeners for showing/hiding the popup (I noticed that when selecting a node or edge and the native pop-up menu shows up, it disappears when you drag those elements, and then reappears when you let go)
  • How to calculate the popup position relative to a canvas element (canvas coordinates and screen/DOM coordinates)
  • The component/class/styling used for canvas popups
  • How to hook into the selection system for custom objects
  • Any example code or plugins that do something similar?

Thank you!