In ScriptUI dialogs, when you click on a button, the status of button.active
changes from false
to true
. The problem occurs when you need to reset the focus (highlighting) of a button or other element: checkbox, text box, etc. This can be seen when the buttons in the dialog are used as switchers.
The onClick
event with a status change can be triggered with one button or another element.
button.onClick = function () {
// do something..
button.active = !button.active;
}
Solution
After clicking the button is active, to reset the state you need to force true
on the active
attribute and then force false
on it again in the script code for the onClick
event. I used this solution in SelectPointsByType in a loop that follows the onClick
event for buttons that are grouped together.
var btns = dialog.add('group');
// ...
for (var i = 0; i < btns.children.length; i++) {
btns.children[i].onClick = function () {
// do something..
// Reset button highlight
this.active = true;
this.active = false;
}
}