• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Engaged ,
Apr 05, 2017 Apr 05, 2017

Copy link to clipboard

Copied

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.value = false;

    }

});

function selected_rbutton (rbuttons) {

    for (var i = 0; i < rbuttons.children.length; i++) {

        if (rbuttons.children.value == true) {

            return rbuttons.children.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");

     break;

     // Linkar com os Scrips.jsx

     case "Radio2":

     alert("This is the Radio 2 script");

     break;

      }

if(check1.value){alert('checkbox (main event)')} 

//else{alert('checkbox 1 is not checked')} 

}

TOPICS
Actions and scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 06, 2017 Apr 06, 2017

You would put in after line 53. Line 52 checks to see if the okay button pressed and runs code accordingly.

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 05, 2017 Apr 05, 2017

Copy link to clipboard

Copied

UI's are just a way to collect values. The order of what the script does is based on the order you list the processes that are derived from the values in the UI. If you want something to show before something else in the ui, you need to have that line of code first. Same for what the script does once you click the okay button. In the above script you have what the radio buttons do first, so naturally, they're going to display their alert first. There is a part of the script that adds an eventListener. I'm not sure what that's suppose to do. It throws an error for me, and it looks like it tries to set all the radio buttons to false. By nature, if you click on a radio button, other within the same group will turn to false, so I don't know what point that part of the code serves.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 06, 2017 Apr 06, 2017

Copy link to clipboard

Copied

Hi Chuck Uebele! Our just add the line of code from the first event before! As for the eventListener, I also do not know what it is for, I found this script on the internet, here it does not generate error for me, but I'll eliminate delete it and test, then I go back

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 06, 2017 Apr 06, 2017

Copy link to clipboard

Copied

In order for the checkbox alert to run first, I understood that I have to put above the code lines of the radio buttons: To work correctly, what line should I add this event to?

If (check1.value) {alert ('checkbox (main event)')}

I put in line 31 but it did not work:

Chuck Uebele Please, would you have any idea? It's not easy for me.

Would you have a simple and small example of yours for the same purpose? Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 06, 2017 Apr 06, 2017

Copy link to clipboard

Copied

You would put in after line 53. Line 52 checks to see if the okay button pressed and runs code accordingly.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 07, 2017 Apr 07, 2017

Copy link to clipboard

Copied

LATEST

Screenshot_1.jpg

Chuck Uebele, thanks to his tip, now yes, it worked perfectly. Once again thank you very much for your attention and this huge help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines