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

Sequential checkbox

Advocate ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

My problem is the following

I would like the scipt to work like this:

if I click first on checkbox 3 then 2 and then 1

when I click ok it must have this sequence 3 - 2 - 1

instead it returns me 1 - 2 - 3

or if I click first on checkbox 2 then 3 and then 1

when I click ok it must have this sequence 2 - 3 - 1

instead it returns me 1 - 2 - 3

I can not figure out how to solve this problem

does anyone have a solution?

win = new Window("dialog", "test");

win.orientation = "column";

test = win.add("group");

ActionButton = test.add("group");

Action_1 = ActionButton.add("checkbox", undefined, "1");

Action_1.minimumSize.width = 20;

Action_2 = ActionButton.add("checkbox", undefined, "2");

Action_2.minimumSize.width = 20;

Action_3 = ActionButton.add("checkbox", undefined, "3");

Action_3.minimumSize.width = 20;

test.orientation = "column";

closeBtn = test.add("button", undefined, "OK");

closeBtn.onClick = function () {

   

    if(Action_1.value) {

alert("test 1");

}

    if(Action_2.value) {

alert("test 2");

}

    if(Action_3.value) {

alert("test 3");

}

close = true;

win.close();

};

win.show();

TOPICS
Actions and scripting

Views

799

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

People's Champ , Jun 23, 2018 Jun 23, 2018

In my opinion SuperMerlin gave the right decision.

Just change your function to this

closeBtn.onClick = function ()

    {

    for (var i = 0; i < arr1.length; i++)

        {

        switch(arr1)

            {

            case 1: alert("test 1"); break;

            case 2: alert("test 2"); break;

            case 3: alert("test 3"); break;

            }

        }

    }

Votes

Translate

Translate
Adobe
Guide ,
Jun 22, 2018 Jun 22, 2018

Copy link to clipboard

Copied

You could do something like...

win = new Window("dialog", "test"); 

var arr1 =[0,0,0];

win.orientation = "column"; 

test = win.add("group"); 

ActionButton = test.add("group"); 

Action_1 = ActionButton.add("checkbox", undefined, "1"); 

Action_1.minimumSize.width = 20; 

Action_1.onClick=function(){

    if(Action_1.value){

        arr1.push(1);

        arr1.shift();

        }

    }

Action_2 = ActionButton.add("checkbox", undefined, "2"); 

Action_2.minimumSize.width = 20; 

Action_2.onClick=function(){

    if(Action_2.value){

        arr1.push(2);

        arr1.shift();

        }

    }

Action_3 = ActionButton.add("checkbox", undefined, "3"); 

Action_3.minimumSize.width = 20; 

Action_3.onClick=function(){

    if(Action_3.value){

        arr1.push(3);

        arr1.shift();

        }

    }

closeBtn = test.add("button", undefined, "OK"); 

closeBtn.onClick = function () {

alert(arr1.toString());

win.close(); 

}; 

win.show();

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
Advocate ,
Jun 23, 2018 Jun 23, 2018

Copy link to clipboard

Copied

SuperMerlin

thanks for the ride

but that's not exactly what I'm looking for

I do not want this window to come out

Schermata 2018-06-23 alle 11.19.47.png

I want that after I click OK

they come out in sequence

the test window 3

and test window 1.

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
Guide ,
Jun 23, 2018 Jun 23, 2018

Copy link to clipboard

Copied

Checkboxs have a value of true or false.

So what you want can not be done.

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
Advocate ,
Jun 23, 2018 Jun 23, 2018

Copy link to clipboard

Copied

I imagined it could not be done

thanks SuperMerlin

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
People's Champ ,
Jun 23, 2018 Jun 23, 2018

Copy link to clipboard

Copied

In my opinion SuperMerlin gave the right decision.

Just change your function to this

closeBtn.onClick = function ()

    {

    for (var i = 0; i < arr1.length; i++)

        {

        switch(arr1)

            {

            case 1: alert("test 1"); break;

            case 2: alert("test 2"); break;

            case 3: alert("test 3"); break;

            }

        }

    }

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
Advocate ,
Jun 23, 2018 Jun 23, 2018

Copy link to clipboard

Copied

r-bin

perfect

thank you so much

Now who should I give the correct answer?

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
Guide ,
Jun 23, 2018 Jun 23, 2018

Copy link to clipboard

Copied

LATEST

Please mark r-bin​ as the correct answer.

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