How To | Disable a button using Lua scripting
Learn how to use Lua scripting to make a button disappear from a page or application.
Procedure
The Component.New() method allows you to gain control over any object in a component, as long as that component has a unique name (i.e., is a named component). This is very useful if you want to make changes on the fly without compiling.
- Drag a scripting component into the design.
- Drag a Custom Controls component into the design and give it a name. (Select the component and type a name - in this example, "Test".)
- Set the custom control to Momentary and drag it into the design.
- Open the script editor. Copy this code snippet into your script:
- Component.New("Test").momentary_1.IsDisabled = true
- Click the yellow tab to save, and then press F6 to emulate the design. You will see the button gray out and become inactive.
- Now, change to this code:
- Component.New("Test").momentary_1.IsInvisible = true
- Save and press F6 to emulate. You should see the button go invisible, which disables it as well.