Skip to main content
A growing collection of fragments of example code…

Right click menus

Background menu

The main background menu (right-click on the canvas) is generated by a call to LGraphCanvas.getCanvasMenuOptions. The standard way of editing this is to implement the getCanvasMenuItems method on your extension:

Node menu

When you right click on a node, the menu is similarly generated by node.getExtraMenuOptions. The standard way is to implement the getNodeMenuItems method on your extension:
If you want a submenu, use the submenu property with an options array:

Capture UI events

This works just like you’d expect - find the UI element in the DOM and add an eventListener. setup() is a good place to do this, since the page has fully loaded. For instance, to detect a click on the ‘Queue’ button:

Detect when a workflow starts

This is one of many api events:

Detect an interrupted workflow

Deprecated: The API hijacking pattern shown below is deprecated and subject to change at any point in the near future. Use the official extension hooks and API event listeners where available.
A simple example of hijacking the api:

Catch clicks on your node

Deprecated: The node method hijacking pattern shown below is deprecated and subject to change at any point in the near future. Use the official extension hooks where available.
node has a mouseDown method you can hijack. This time we’re careful to pass on any return value.