Skip to main content
dublove
Legend
Nov 8, 2026 5:30 AM UTC
Answered

Is it possible to allow only one of the two checkboxes to be selected?

Hello everyone.

I just want to use a checkbox here.
But I also want it to be like a radiobutton, allowing only one selection.

Alternatively, use the properties of radiobutton but change the shape of the front to resemble a "box" similar to the checkbox


Another question: How to make the radiobutton indent 4mm to the right?

var pmWidth = 200;
makeDialog();

/**
* Make the dialog
* @ return void
*/

function makeDialog() {
var theDialog = app.dialogs.add({ name: "Select your need", canCancel: true });
with (theDialog) {
with (dialogColumns.add()) {

//Panel 1 Enabling
var enablePanel_A = enablingGroups.add({ staticLabel: "Doo1", checkedState: false, minWidth: pmWidth })
with (enablePanel_A) {
with (radiobuttonGroups.add()) {
opa = radiobuttonControls.add({ checkedState: false });
}
with (dialogColumns.add()) {
var w1 = staticTexts.add({ staticLabel: "Doo1-01" });
}
}

//Panel 2 Enabling
var enablePanel_B = enablingGroups.add({ staticLabel: "Doo2", checkedState: false, minWidth: pmWidth, })
with (enablePanel_B) {
with (radiobuttonGroups.add()) {
opb = radiobuttonControls.add({ checkedState: false });
}
with (dialogColumns.add()) {
var w2 = staticTexts.add({ staticLabel: "Doo2-01" });
}
}
}
}

var res = theDialog.show();
theDialog.destroy();

}

 

    Eugene TysonCorrect answer
    Community Expert
    Nov 8, 2026 9:25 AM UTC

    As I understand what you want

    enablePanel_A

    and

    enablePanel_B`

    to behave like radio buttons, so enabling one automatically disables the other.

     

    Unfortunately, InDesign's native app.dialogs EnablingGroups don't support this exactly..

    Each has its own independent checkedState

     

    You could check their states after the dialog closes, but that wouldn't prevent both being selected while the dialog is open.

     

    I'd suggest using ScriptUI instead

    You can create two checkboxes with onClick handlers so that selecting one automatically deselects the other. You can also enable or disable the associated controls.

     

    That would give you the square checkbox appearance you want, with radio-button behaviour, and more control over the positioning and indentation.


    Something like this shows the method but it’s not exactly correct.


    var dlg = new Window("dialog", "Select your need");
    dlg.orientation = "column";
    dlg.alignChildren = "fill";

    // First option
    var cbA = dlg.add("checkbox", undefined, "Doo1");
    var panelA = dlg.add("panel");
    panelA.add("statictext", undefined, "Doo1-01");

    // Second option
    var cbB = dlg.add("checkbox", undefined, "Doo2");
    var panelB = dlg.add("panel");
    panelB.add("statictext", undefined, "Doo2-01");

    // Keep exactly one checkbox selected
    function selectOption(option) {
    cbA.value = (option === 1);
    cbB.value = (option === 2);

    panelA.enabled = cbA.value;
    panelB.enabled = cbB.value;
    }

    cbA.onClick = function() {
    selectOption(1);
    };

    cbB.onClick = function() {
    selectOption(2);
    };

    // Start with Doo1 selected
    selectOption(1);

    dlg.add("button", undefined, "OK", {name: "ok"});
    dlg.add("button", undefined, "Cancel", {name: "cancel"});

    if (dlg.show() === 1) {
    alert(cbA.value ? "Doo1 selected" : "Doo2 selected");
    }

     

    square checkboxes with selection the controls that become enabled or disabled.

    ScriptUI also supports layout margins, which would make positioning controls easier than in native InDesign dialogs. 
    https://extendscript.docsforadobe.dev/user-interface-tools/defining-behavior-with-event-callbacks-and-listeners/


    ScriptUI isn't the same as InDesign's native app.dialogs system. If you absolutely need to retain the original EnablingGroups you won't get the same interactive behaviour.

    6 replies

    rob day
    Community Expert
    Community Expert
    Nov 8, 2026 1:02 PM UTC

    Hi ​@dublove . This is a good example of why there is the window object and also the application’s dialog object.

     

    The dialog’s dialogColumn and dialogRow objects have a number of built in objects  making it a lot easier to design dialogs, but with limits. There is a radiobuttonGroup, but not a checkboxGroup—for that you need to use the the window object as ​@Eugene Tyson  is showing.

    Translate
    Eugene TysonCommunity ExpertCorrect answer
    Community Expert
    Nov 8, 2026 9:25 AM UTC

    As I understand what you want

    enablePanel_A

    and

    enablePanel_B`

    to behave like radio buttons, so enabling one automatically disables the other.

     

    Unfortunately, InDesign's native app.dialogs EnablingGroups don't support this exactly..

    Each has its own independent checkedState

     

    You could check their states after the dialog closes, but that wouldn't prevent both being selected while the dialog is open.

     

    I'd suggest using ScriptUI instead

    You can create two checkboxes with onClick handlers so that selecting one automatically deselects the other. You can also enable or disable the associated controls.

     

    That would give you the square checkbox appearance you want, with radio-button behaviour, and more control over the positioning and indentation.


    Something like this shows the method but it’s not exactly correct.


    var dlg = new Window("dialog", "Select your need");
    dlg.orientation = "column";
    dlg.alignChildren = "fill";

    // First option
    var cbA = dlg.add("checkbox", undefined, "Doo1");
    var panelA = dlg.add("panel");
    panelA.add("statictext", undefined, "Doo1-01");

    // Second option
    var cbB = dlg.add("checkbox", undefined, "Doo2");
    var panelB = dlg.add("panel");
    panelB.add("statictext", undefined, "Doo2-01");

    // Keep exactly one checkbox selected
    function selectOption(option) {
    cbA.value = (option === 1);
    cbB.value = (option === 2);

    panelA.enabled = cbA.value;
    panelB.enabled = cbB.value;
    }

    cbA.onClick = function() {
    selectOption(1);
    };

    cbB.onClick = function() {
    selectOption(2);
    };

    // Start with Doo1 selected
    selectOption(1);

    dlg.add("button", undefined, "OK", {name: "ok"});
    dlg.add("button", undefined, "Cancel", {name: "cancel"});

    if (dlg.show() === 1) {
    alert(cbA.value ? "Doo1 selected" : "Doo2 selected");
    }

     

    square checkboxes with selection the controls that become enabled or disabled.

    ScriptUI also supports layout margins, which would make positioning controls easier than in native InDesign dialogs. 
    https://extendscript.docsforadobe.dev/user-interface-tools/defining-behavior-with-event-callbacks-and-listeners/


    ScriptUI isn't the same as InDesign's native app.dialogs system. If you absolutely need to retain the original EnablingGroups you won't get the same interactive behaviour.

    Translate
    dublove
    dubloveAuthor
    Legend
    Nov 8, 2026 2:39 PM UTC

    Hi ​@Eugene Tyson 

    Thank you very much.

    When you click the Cancel button, an exception will be thrown.
    Can I exit directly by clicking on 'cancel'?

    Translate
    Community Expert
    Nov 8, 2026 2:43 PM UTC

    It was just an example. I haven't checked it thoroughly. Will be back online tomorrow. 

    Translate
    CORCTON34033231
    Community Expert
    Community Expert
    Nov 8, 2026 6:02 AM UTC

    Hi dublove,

     

    The reason both can be selected is that you created two separate RadiobuttonGroups — one inside each EnablingGroup. Mutual exclusivity only exists inside a single group: a RadiobuttonGroup keeps one selectedButton index, so your two groups each keep their own selection independently.

     

    To get the behaviour you want, put both RadiobuttonControls in one shared RadiobuttonGroup:

     

    with (dialogColumns.add()) {

        with (radiobuttonGroups.add()) {

            opa = radiobuttonControls.add({staticLabel: "Doo1", checkedState: true});

            opb = radiobuttonControls.add({staticLabel: "Doo2", checkedState: false});

        }

    }

     

    The trade-off is that the two buttons then can't stay in two different EnablingGroups, because the group boundary is what defines the exclusivity — keep the EnablingGroups for the other controls, and place the shared radio group outside them.

     

    On the shape: a RadiobuttonControl can't be restyled to look like a checkbox. The object model only exposes checkedState, minWidth and staticLabel for it — there is no appearance property. If the square checkbox look is essential, use CheckboxControls instead, but those are independent toggles, so you would need to read both values after theDialog.show() and handle the case where both are ticked.

     

    The same applies to the indent: RadiobuttonControl has no indent or margin property, and an app.dialogs dialog is laid out in fixed columns and rows, so there is no direct way to shift a single radio button 4 mm to the right.

     

    References (InDesign object model):

    RadiobuttonGroup — https://www.indesignjs.de/indesignapi/indesign/RadiobuttonGroup.html

    RadiobuttonControl — https://www.indesignjs.de/indesignapi/indesign/RadiobuttonControl.html

    Translate
    dublove
    dubloveAuthor
    Legend
    Nov 8, 2026 7:47 AM UTC

    Hi ​@CORCTON34033231 

    What I meant was:
    var enablePanel_A = enablingGroups.add({ staticLabel: "Doo1", checkedState: false, minWidth: pmWidth })
    and
    var enablePanel_B = enablingGroups.add({ staticLabel: "Doo2", checkedState: false, minWidth: pmWidth, })

    I can only choose one.

    Translate