Category: How do I do X?


This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How do I disable/enable two differrent widgets?


I need help enabling only one widget at a time - either an input or a select widget. Whenever I write a number in the input widget, the select widget should be disabled and vice versa. I tried using {{input.isDisabled}} and {{sel.isDisabled}}, but it's not working correctly. How can I properly disable these widgets?


To enable only one widget at a time, such as an input widget or a select widget, you can use the storeValue() method in the onTextChanged and onOptionChange events. Doing so will conditionally disable one widget depending on the other's status.

For example, if you write a number in the input widget, you can disable the select widget by using storeValue() to set a value to the selected option and then disabling the select widget. Conversely, if an item is selected from the select widget, you can disable the input widget by using storeValue() to store the input's value and then disabling the input widget.

Here's an example code snippet:

const select = widget.inputs.select1;const input = widget.inputs.input1;select.onOptionChange = function() {  const value = select.getValue();  widget.setProperty("selectedOption", value);  input.storeValue("inputValue", "");  input.disable(true);}input.onTextChanged = function() {  const value = input.getValue();  widget.setProperty("inputValue", value);  select.storeValue("selectedOption", null);  select.disable(true);}

In this example, the "selectedOption" and "inputValue" properties are set to store and retrieve values for each widget. The widget's disable() method is then used to conditionally disable the other widget based on the current widget's status.