Annotated Examples
A growing collection of fragments of example code…
Comfy UI preference settings
Add and read a setting
Sliders for numbers
The type slider
lets the user enter a value directly or via a slider:
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…
Submenus
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.
Was this page helpful?