How To | Make a button disappear using Lua scripting

Learn how to use Lua scripting to make a button disappear from a page or application.

Updated at May 4th, 2023

Your engagement helps us create the content you need. Click here to review this article.



Table of Contents

Procedure


The Component.New() method allows you to gain control over any object in a component, as long as that component has a “pretty name” (i.e., is a named component).  This is very useful if you want to change something on the fly without compiling.

  1. Drag a scripting component into the design.
  2. Drag a Custom Controls component into the design and give it a name. (Select the component and type a name - in this example, "Test".)
  3. Set the custom control to Momentary and drag it into the design.
  4. Open the script editor. Copy this code snippet into your script:
    • Component.New("Test").momentary_1.IsDisabled = true
  5. Click the yellow tab to save, and then press F6 to emulate the design. You will see the button gray out and become inactive.
  6. Now, change to this code:
    • Component.New("Test").momentary_1.IsInvisible = true
  7. Save and press F6 to emulate. You should see the button go invisible, which disables it as well.