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
LGraph.getCanvasMenuOptions. One way to add your own menu options is to hijack this call:

Node menu

When you right click on a node, the menu is similarly generated by node.getExtraMenuOptions. But instead of returning an options object, this one gets it passed in…
If you want a submenu, provide a callback which uses LiteGraph.ContextMenu to create it:

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

A simple example of hijacking the api:

Catch clicks on your node

node has a mouseDown method you can hijack. This time we’re careful to pass on any return value.