Basic Usage
To add commands to the selection toolbox, your extension needs to:- Define commands with the standard command interface
- Implement the
getSelectionToolboxCommandsmethod to specify which commands appear in the toolbox
getSelectionToolboxCommands method is called for each item in the selection set whenever a new selection is made.
Command Definition
Commands for the selection toolbox use the standard ComfyUI command interface:function receives the selected item(s) as a parameter, allowing you to perform actions on the current selection.
Icon Options
Selection toolbox buttons support the same icon libraries as other UI elements:- PrimeVue icons:
pi pi-[icon-name](e.g.,pi pi-star) - Material Design icons:
mdi mdi-[icon-name](e.g.,mdi mdi-content-copy)
Dynamic Command Visibility
ThegetSelectionToolboxCommands method is called each time the selection changes, allowing you to show different commands based on what’s selected:
Working with Selected Items
Access information about selected items through the app’s canvas object. TheselectedItems property is a Set that includes nodes, groups, and other canvas elements:
Complete Example
Here’s a simple example showing various selection toolbox features:Notes
- The selection toolbox must be enabled in settings:
Comfy.Canvas.SelectionToolbox - Commands must be defined in the
commandsarray before being referenced ingetSelectionToolboxCommands - The toolbox automatically updates when the selection changes
- The
getSelectionToolboxCommandsmethod is called for each item in the selection set whenever a new selection is made - Use
app.canvas.selectedItems(a Set) to access all selected items including nodes, groups, and other canvas elements - For backward compatibility,
app.canvas.selected_nodesstill exists but only contains nodes