Adding a Button in a Macro

Why on earth would we want a button in a macro?

A button can run any OS command, so you can do alot. I am however going to keep this practical and for all the people out there that make macros for others. Our button will open a webpage, this webpage could be your website or even a YouTube video with instructions.

NB. A button can execute a script, run a fuse, or any known operating system command.

Adding a button is the same as adding a label or drop-down and can be completed inside resolve. However, you may want to edit the code to ensure the button works correctly on both Mac & Windows. Also, we can move the button to any location via the code.

Assumptions

  • You are on the fusion page
  • You are either modifying an existing tool/effect or creating your own.
  • The result will be a GroupOperator/MacroOperator
  • The result can be for fusion, edit page, or cut page.
  1. Select the node you want the Button on.
  2. Right-click and choose “Edit Controls”
  3. Over Type Name: “New Control” with your button title
  4. Leave “Type” as “Number”
  5. Select the “Page” you want the label to be on (User)
  6. Uncheck “Animatable”
  7. Check “Passive”
  8. Input Crtl select ButtonControl
  9. Enter in the Execute box “os.execute(‘start “” “your url“‘) –Windows
  10. Select “OK”

9A. Enter “os.execute(‘open “” “your url“‘) –Mac10. Select “OK”
The button will now appear at the bottom of the inspector on the page you selected. As long as the URL you entered is correct when you click on the button, the default web browser will open and navigate to it. The computer terminal or command prompt will flash on the screen for a millisecond as we have just triggered an OS command.

Hold the phone! What if you don’t know the operating system this will be used on, well we are back to coding. (Although I have read that “open” will work on Mac or Windows).
The section of code we need to tweak will be the section created when we went into “Edit Controls” This generates the section called UserControls.

  1.                                   UserControls = ordered() {
  2. Button = {
  3. LINKS_Name = “Button”,
  4. LINKID_DataType = “Number”,
  5. INPID_InputControl = “ButtonControl”,
  6. INP_Integer = false,
  7. INP_External = false,
  8. INP_Passive = true,
  9. BTNCS_Execute = [[
  10.                      os.execute(‘open “” “https://www.blackmagicdesign.com/”‘)
  11.                      os.execute(‘start “” “https://www.blackmagicdesign.com/”‘)
  12.                      ]],
  13. },

Line 8 is helpful

This helps speed up your comp, anything set to passive does not render. You would use passive for any decorative elements such as Labels, Dividers & buttons.

Adding lines 9, 10, 11 & 12 sets the button to open in Mac or Windows.
BTNCS_Execute = is a powerful command and can run almost anything.
The URL does not have to be a webpage it can also be a file path on the computer, so you could open a local webpage or a pdf file. 
If you require 2 buttons then just add another button to the same node, and then set the “width” to 0.5. width is above the execute box.

Tooltips

An interesting feature of buttons is the ability to add tooltips on hover. Add the following code to your button will add tool tips. The MBTNCD_ButtonWidth = 1 is the width of the button in the inspector. Think of it as a percentage, 1 = 100%, 0.5 = 50% etc

{ MBTNCS_ToolTip = “Main Title Template”, MBTNC_AddButton = “Main Title”, MBTNCD_ButtonWidth = 1 },                            {

That’s it!
Thanks for taking the time to read this post and if you would like to buy me a coffee or a pizza then it is greatly appreciated.
https://www.buymeacoffee.com/mrjholt

Listen to this article