Using the setEnabled Method to change the visibility of a control

There are various controls that have the "setEnabled" method, which handles the visibility of the control. This article will cover how we can call that method from the Events configuration option, as well as some practical ways to call it from other controls.

In this article we will be using a text control and calling the setEnabled method various ways.

On Load

Calling the the setEnabled as such: me.setEnabled(false) within the On Load event will make the control "read only" at runtime. This is the same as setting the visibility to "read only" in the properties tab of the control. 

Setting from other Controls

In this example we will be setting the visibility of the text control to read only when we click a button. A text and button control have been added to the coach.

In the On Click event of the button control we call the setEnabled method as such: ${Text1}.setEnabled(false)

The "Text1" is the control id of the text control.

At runtime, clicking the button will make the text control read only.


This method could be very useful when created a coach that has optional controls that are set back and forth between "read only" and "editable". In the following example, two text controls and a checkbox control have been added to the coach.

The first text control is labeled as "Required Text", and the second one has been labeled as "Optional Text". The option text will be set be enabled only if the checkbox is checked.

First, the optional text control is set to read only, so that it can be enabled after the checkbox. Within the On Load event of the optional text, the setEnabled method is call as such: me.setEnabled(false)

Then, the same method needs to be called on the optional text, but this time it is called from the On Change event of the checkbox control.

if(me.isChecked() == true){${OptionText1}.setEnabled(true)}

This code first checks if the checkbox has been check. If it has, then we call the setEnabled method on the optional text with "true" as a parameter.

At runtime with the checkbox checked...


The final step is to set the optional text back to read only after the checkbox is unchecked. To do this, we add an else statement to the if statement on the checkbox:

if(me.isChecked() == true){${Text1}.setEnabled(true)}else {${Text1}.setEnabled(false)}

At runtime...



  • Author: Erick Quintanilla
  • Date Created: October 30, 2015
  • Date Modified: October 30, 2015
Was this article helpful?
0 out of 0 found this helpful