showWhen()
Shows a question, text or container only while a checkbox is ticked, or while an option is chosen. Every dialog item has it.
Signature
showWhen(checkBoxId: number): DialogComponent
showWhen(radioGroupId: number, optionId: number): DialogComponent
Parameters
| Parameters | Type | Description |
|---|---|---|
| checkBoxId | number | Show while the CheckBox with this id is ticked |
| radioGroupId | number | The RadioGroup (or dropdown) to watch |
| optionId | number | Show while the RadioButton with this id is chosen |
Returns
The same item, so calls can chain
Example
Dialog:add(CheckBox(1, "Collect daily rewards"))
Dialog:add(NumberInput(2, "Rewards to collect", 3):showWhen(1))
local mode = RadioGroup(3, 1)
mode:add(RadioButton(1, "Farm"))
mode:add(RadioButton(2, "Arena"))
Dialog:add(mode)
Dialog:add(TapPicker(4, "Tap the Arena button"):showWhen(3, 2))
Notes
- For the opposite, use
hideWhen(). - A hidden question never keeps OK grey, and keeps its last answer.
- If the watched checkbox or group is hidden itself, the item hides too.
- Watching an id that isn't a
CheckBoxorRadioGroup, or aRadioGroupwithout anoptionId, stops the dialog with an error.