Docs Core
OpMenuRegistry
OP Create dialog surface registry: search words, row decorations, right-click items, filter stages. The raw master, promoted to /sys.
◈ Core
Why use it
The OP Create dialog, where you pick every operator you add to a network, is a single piece of TouchDesigner's UI that several tools want to change at once. OpMenuMods adds search words and Greg Hermanovic's IO filters to it, OpTemplates marks the operator types you have a template for and adds an Edit Templates... item, and any tool can offer itself as an alternative to a stock operator. If each of them patched the dialog on its own, they would overwrite each other's changes, the last one installed would win, and removing a tool would leave its patches behind.
OpMenuRegistry is where those changes meet. Each tool contributes, the registry combines the contributions and applies them, and when the tools are removed the dialog goes back to stock.
Features
- Shared OP Create dialog surfaceArbitrates between the tools that change the OP Create dialog, and the dialog goes back to stock when those tools are removed.
- Arrange contributions in HubHub's OpMenu tab reorders what the tools add to the dialog and switches any contribution off without uninstalling its tool.
- Replace a stock operator with an alternativeCreate a stock operator type with the alternatives shortcut held and installed alternatives are offered; one is placed with its wiring restored, several open a picker.
- Alternatives from the storeAlternatives from tools downloaded to your store but not in the project are offered below a divider and placed from disk; >> marks such types.
- Search word contributionsTools add extra words that match an operator type, so searching music finds Audio File In.
- Row decorationsTools relabel rows in the operator list, such as the >>> OpTemplates puts beside every type you have a template for.
- Right-click menu itemsTools add entries after TouchDesigner's own three in the dialog's right-click menu, such as OpTemplates' Edit Templates.
- Filter-chain stagesTools splice Script DATs into the operator list's filter chain to filter or rewrite the list itself.
- Panel injectionTools wire Panel COMPs into the dialog at a named anchor.
- Callbacks DAT inside each toolA tool's whole contribution is one opmenu_callbacks DAT inside the tool, so its menu behaviour travels in its own .tox.
How to use it
The registry is part of the toolkit's core and installs with it. What you see
depends on which tools you have: words that find an operator under a name of
your own, the >>> beside types with a template, IO filter buttons at the top
right of the dialog, extra items when you right-click a row.
- To reorder or switch off a contribution, open the OpMenu tab of Hub (left-click the FNS button in the main-menu bar). Switching one off keeps its tool installed.
- To use an alternative, create a stock operator type with the
alternatives shortcut held:
Ctrl+Altby default (Cmd+Ctrlon macOS), set by Alternatives Shortcut on the registry's Alternatives page. Without the keys the operator is created as normal. With them, every alternative any installed tool declared for that type is offered: a single one is placed in the fresh operator's spot with its wiring restored, several open a picker. - Tools you have downloaded but not added to the project are offered too,
below a divider, and placed from disk when you pick them. In the operator
list,
>>>marks a type with an alternative in the project and>>one whose only alternatives are in the store.
What tools contribute
Six kinds of contribution, and the code for every one of them lives in the
publishing tool, in a callbacks DAT that tool owns. The registry holds only a
reference to it, so it never names a tool, and a tool's menu behaviour
travels inside its own .tox.
- Search words: extra words that match an operator type, so
musicfinds Audio File In. OpMenuMods' custom search keywords work this way. - Row decorations: relabel a row, such as the
>>>that OpTemplates puts beside every type you have a template for. - Right-click menu items: entries appended after TouchDesigner's own three (Help, Python Help, Operator Snippets), such as OpTemplates' Edit Templates....
- Filter-chain stages: Script DATs spliced into the operator list's filter chain to filter or rewrite the list itself. Greg Hermanovic's IO filters in OpMenuMods are the worked example.
- Panels: Panel COMPs wired into the dialog at a named anchor.
- Alternatives: a tool, or a library of chains, that stands in for a stock operator type. OpTemplates is the first contributor.
For tool authors
A tool contributes through one registry host and one callbacks DAT, however many kinds of contribution it makes:
- Put an OpMenuRegistry host in your tool (copy one from a shipped tool, or
op.FNS.op('FNS_OpMenuRegistry').StampHost(tool, canonical_name='MyTool')). Leave Widget COMP on the tool (.., the default) and set Canonical Name. - Press Create Callbacks. It puts an
opmenu_callbacksDAT into your tool from the registry's template and points Callback DAT at it. Pressing it again adopts the existing DAT and never overwrites it. - Fill in the hooks you want and switch on Auto-register.
The pulse is also promoted onto the tool's own Registry page, so the whole setup works without opening the host.
Every hook is optional. The registry checks which ones the DAT defines and
uses those; as the template ships, each returns empty and the tool contributes
nothing. me.parent() is your tool, so resolve everything from there, never
by absolute path.
| Hook | Returns | When |
|---|---|---|
onSearchWords() |
{opType: [word, ...]} |
merged into the dialog's search |
onDecorateLabel(opType, label) |
a new label, or None |
once per visible row, per cook: keep it cheap |
onMenuItems() |
[label, ...] |
appended after TouchDesigner's own three items |
onMenuItem(label, opType) |
nothing | one of your items was clicked |
onChainNodes() |
[scriptDAT, ...] |
stages spliced into the operator list's filter chain, in order |
onPanels() |
[(comp, anchor_name), ...] |
panels injected into the dialog, wired to anchor_name |
onAlternatives() |
{opType: [alternative, ...]} |
offered when that type is created with the shortcut held |
def onSearchWords():
return {'noiseTOP': ['grain', 'fractal', 'perlin']}
def onAlternatives():
# a key may name several types, separated by spaces
return {'moviefileinTOP ndiinTOP': [{'label': me.parent().name,
'source': me.parent(),
'help': 'One line on what it does.'}]}
An alternative is {'label': str, 'source': OP, 'help': str}. A COMP source
is placed whole, as one node, wired through its In and Out operators; add
'unpack': True to copy its children out instead, for a library base that
holds a chain. A bare operator is accepted, labelled with its name, and
unpacks. A tool whose shipped set can differ from its active one, such as a
library the user edits, can also define onShippedAlternatives() in the same
shape to name what ships in its .tox.
A panel needs an anchor: without one it drops out of the dialog's layout and
stays invisible. searchpanel puts it beside the search field. For a single
panel there is a zero-code path: set Panel and Panel Anchor on the
host and leave the callbacks DAT out. It adds to whatever onPanels()
returns.
Live toggles. Returning an empty list or dict withdraws a contribution,
and the registry removes whatever it had injected for it. To make one
conditional, decide it in your callbacks (it is your tool's decision) and
call op.FNS_OPMENUREGISTRY.Resync() when the condition changes. A hook that
raises is contained: it is reported with debug(), skipped, and the dialog
keeps working.
Get it
Tick it on the install page and it installs with the rest of your setup and stays up to date.
Download FNS_OpMenuRegistry.tox Version 3.2.8, the tool on its own. It works in any project, and this copy never updates itself.
Parameters
Registration
| Control | Type / default | What it does |
|---|---|---|
Widget COMPComp |
operator.. | Panel COMP published as the toolbar widget. Defaults to the parent component. |
Canonical NameCanonicalname |
textempty | Unique name for this widget in the global toolbar registry. |
Callback DATCallback |
operatorempty | Optional DAT with toolbar callbacks for this widget. |
Create CallbacksCreatecallbacks |
button | Spawn an 'opmenu_callbacks' DAT into this tool from the registry's template and wire this host's Callback parameter to it. Safe to pulse again: an existing DAT is adopted, never overwritten. |
PanelPanel |
operatorempty | A Panel COMP to inject into /ui/dialogs/menu_op. The zero-code way to contribute a panel, with no callbacks DAT needed. Combined with anything onPanels() returns, not overridden by it. |
Panel AnchorPanelanchor |
textsearchpanel | Name of a panel inside /ui/dialogs/menu_op whose output the injected panel's input is wired to. Without it the panel drops out of the dialog's layout flow. Default: searchpanel. |
Auto-registerAutoregister |
on / offoff | When on, keep this widget published into the global toolbar registry while this component exists. |
RegisterRegister |
button | Publish once into the global toolbar registry, even if Auto-register is off. |
UnregisterUnregister |
button | Take this tool's contribution back out of the registry and turn Autoregister off, so it stays out. Register puts it back. |
Registration StatusRegstatusread-only |
textempty | Read-only status of this host registration. |
Contribution OrderMenuorder |
number-1 | Preferred order among registered widgets, managed by the global registry. -1 = no preference (append at the end). |
DisplayedDisplayed |
on / offon | Default visibility of the widget in the toolbar (managed by the global registry). |
Help URLHelpurl |
textempty | The tool's wiki/help page opened from the Configurator (right-click the Name cell). Leave empty to auto-discover from a docsHelper COMP (its Url par) inside the registered panel or its parent. |
Promote ParametersPromotepars |
on / offon | When on, the host mirrors its key Registration parameters onto the parent tool as a bound 'Registry' page. Turn off before shipping a tool that should not expose registry controls. |
Pre-Save HealPresaveheal |
on / offon | Before each project save, re-check this registry: update entries whose component moved, drop entries whose component is gone, and republish a host that initialised before the global registry existed. Off skips the sweep for this registry only. |
Alternatives
| Control | Type / default | What it does |
|---|---|---|
Alternatives ShortcutShortcutalternatives |
textalt ctrl | Modifier keys to hold while creating an operator to be offered the alternatives registered for its type (space-separated: alt, ctrl, shift, cmd). Without the keys the operator is created as normal. Applies on the /sys global; the master holds the value the global is promoted with. |
What it adds to a registered tool
Every tool that registers gets these on its own Registry page.
| Control | Type / default | What it does |
|---|---|---|
Create CallbacksCreatecallbacks |
button | Spawn an 'opmenu_callbacks' DAT into this tool from the registry's template and wire this host's Callback parameter to it. Safe to pulse again: an existing DAT is adopted, never overwritten. |
Auto-registerAutoregister |
on / offoff | When on, keep this widget published into the global toolbar registry while this component exists. |
RegisterRegister |
button | Publish once into the global toolbar registry, even if Auto-register is off. |
UnregisterUnregister |
button | Take this tool's contribution back out of the registry and turn Autoregister off, so it stays out. Register puts it back. |
Registration StatusRegstatusread-only |
textempty | Read-only status of this host registration. |
Contribution OrderMenuorder |
number-1 | Preferred order among registered widgets, managed by the global registry. -1 = no preference (append at the end). |
DisplayedDisplayed |
on / offon | Default visibility of the widget in the toolbar (managed by the global registry). |