How to add a menu port to a subnetwork

john's Avatar

john

24 Jun, 2024 12:46 AM

People occasionally ask how I make the menus in the subnetworks I publish in my library. This is not well-documented, so I thought I'd explain it again in a separate post that might be easier to find...

To make a subnetwork with a menu port:

  • Create a subnetwork and publish a string node (even if you want to use it to make numbers).
  • Then go back up, select your subnetwork, and open the Metadata dialog.
  • Select the string port from the list on the left
  • Change Widget (on the right) from String to Menu
  • At the bottom right of the dialog, press the plus button to add your first menu option
  • For each option, supply a Key and a Label. The Key will be the value received through that port; the Label will be the description text that appears in the menu
  • You can use the other buttons to delete or reorder menu items; click on an existing menu item to edit it.
  • Click OK to close the dialog. Your menu is now ready to use. It will be empty until you set it to an option the first time.

Inside your subnetwork you can then turn that string into a number if you want (or not). I usually define keys of 0, 1, 2... and then feed it directly into a switch node.

It's pretty nice. All that power hidden away in the Metadata dialog. And even though the port now functions as a user-friendly menu, you can still feed it key values directly from another node. My image node has seven levels of quality, but you can also just feed it the number of kilo-pixels directly from another node.

Notice that when you publish a string you have a number of other widget options:

  • Data - used for the Freehand node; don't see how we can use this more generally
  • File - provides a button with a 3 dots icon that summons a file dialog; from this you can derive a file path
  • Font - lets you select a system font
  • Image - like File except that it restricts your choices to PNGs, JPEGs, GIFs, etc.
  • Menu - described above
  • String - a normal string field
  • Text - seems to work just like string; I don't know if there's any difference

Note: to add a checkbox just publish a boolean node.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

14 Mar, 2025 08:32 AM
10 Mar, 2025 06:36 PM
10 Mar, 2025 06:36 PM
10 Mar, 2025 06:36 PM
10 Mar, 2025 12:30 AM

 

02 Mar, 2025 12:34 AM
01 Mar, 2025 12:27 AM
24 Feb, 2025 11:24 PM
24 Feb, 2025 08:19 AM
24 Feb, 2025 01:07 AM
23 Feb, 2025 11:42 PM