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
Alexander Ladygin suggested a universal trick: add a new element to the dialog, activate it, and delete it. 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
var temp = dialog.add('checkbox', undefined, 'checkbox');
temp.active = true;
dialog.update();
temp.remove();
dialog.update();
}
}