5 Replies Latest reply on Apr 7, 2017 4:55 AM by smithcgl9043167

    Help with UI: Script execution order when selecting Radio and Checkbox options

    smithcgl9043167 Level 2

      I need to modify a dialog box that contains Radio and Checkbox options to run two different events on the same task, however, I'm having a huge Difficulty in defining the order of execution of events: The script contains two groups: "Group 1 (Radio)" and "Group2 (Checkbox)". I would like the events to run in the following order: "Group 1 (Radio)" = Second Event "Group 2 (Checkbox)" = First Event (main event). Run all selected events after clicking OK button.

      Could some friend as a greater knowledge help me?

      Thank you. It would be a reversal in the order of running the events of this script:

      var w = new Window ("dialog", " My ScriptUI");
          w.orientation = "column";      
          w.alignChildren = "top";  // insert this line  
      var g1 = w.add('group')
          g1.orientation = 'row';
          var radio_group  = g1.add ('panel', undefined, "Group1");
          // Radio
              radio_group.alignChildren = "left";
              radio_group.add ("radiobutton", undefined, "Radio1");
              radio_group.add ("radiobutton", undefined, "Radio2");
              radio_group.add ("radiobutton", undefined, "Radio3");
          var btnGroup = g1.add("group");    
              btnGroup.orientation = "column";
              btnGroup.alignment = ['left','top'];  
              btnGroup.add ('button', {x:90, y:125, width:80, height:25}, 'Ok', {name:'ok'});
              btnGroup.add ('button', {x:240, y:125, width:80, height:25}, 'Cancel', {name:'cancel'});
      var g2 = w.add('group')
          g2.orientation = 'row';
          g2.alignment = ['left','top'];  
          // Checkbox
          var check_gp = g2.add('panel',undefined,'Group2');  
              check_gp.orientation = 'row';  
              check_gp.alignChildren = ['left','top'];  
              var check1 = check_gp.add('checkbox',undefined,'checkbox');  
              check1.value = false;  
      // set dialog defaults
      radio_group.children[0].value = true;
      radio_group.addEventListener('click', function(evt) {
          for (var i = 0, _len = radio_group2.children.length; i < _len; i++) {
              radio_group2.children[i].value = false;
      function selected_rbutton (rbuttons) {
          for (var i = 0; i < rbuttons.children.length; i++) {
              if (rbuttons.children[i].value == true) {
                  return rbuttons.children[i].text;
          return false;
       // Linkar com os Scrips.jsx
       if (w.show () == 1) {
          var chosenRadioButton = selected_rbutton(radio_group) || selected_rbutton(radio_group2) || selected_rbutton(radio_group3);
          switch (chosenRadioButton) {
           // Linkar com os Scrips.jsx  
           case "Radio1":
           alert("This is the Radio 1 script");
           // Linkar com os Scrips.jsx
           case "Radio2":
           alert("This is the Radio 2 script");
      if(check1.value){alert('checkbox (main event)')}  
      //else{alert('checkbox 1 is not checked')}