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

Preference in checkboxes in the user interface.

Contributor ,
Jul 26, 2018 Jul 26, 2018

Hello guys! Preference in checkboxes in the user interface.

Situation:

When I open the dialog box with a checkbox enabled by default, when clicking the Apply button will certainly

Will do something and close the window, or if I disable and click the apply button, will certainly do something else and close the window however if I open the window again I would very much like the checkbox

Remain disabled.

In short: If I end with checkbox enabled, please next time open enabled and if I end with the checkbox disabled, please open disabled.

Is there any way to add a command that automates this task? Thank you.

var w = new Window("dialog", "Preference Checkebox");   

      var radio_group = w.add('panel', undefined, "Radio");   

      var check_gp = w.add('panel',undefined,'check boxes'); 

      var check1 = check_gp.add('checkbox',undefined,'checkbox '); 

      check1.value = true; 

      var btn = w.add("button", {x:256, y:11, width:93,height:25}, "Aplay", { name: "ok"});

   

     btn.onClick = function (){

    if(check1.value){alert('enabled')} 

        else{alert('disabled')} 

   w.close()

}

w.show()

TOPICS
Actions and scripting
1.4K
Translate
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 , Jul 26, 2018 Jul 26, 2018

var settings = new File(app.preferencesFolder + "/{06704d4d-4e32-4c26-87ab-78d674f1eeab}.dat")

if (settings.exists) $.evalFile(settings);

var check1_value;

if (check1_value == undefined) check1_value = true;

var w = new Window("dialog", "Preference Checkebox");     

      var radio_group = w.add('panel', undefined, "Radio");     

      var check_gp = w.add('panel',undefined,'check boxes');   

      var check1 = check_gp.add('checkbox',undefined,'checkbox ');   

      check1.value = check1_value;   

...
Translate
Adobe
People's Champ ,
Jul 26, 2018 Jul 26, 2018

var settings = new File(app.preferencesFolder + "/{06704d4d-4e32-4c26-87ab-78d674f1eeab}.dat")

if (settings.exists) $.evalFile(settings);

var check1_value;

if (check1_value == undefined) check1_value = true;

var w = new Window("dialog", "Preference Checkebox");     

      var radio_group = w.add('panel', undefined, "Radio");     

      var check_gp = w.add('panel',undefined,'check boxes');   

      var check1 = check_gp.add('checkbox',undefined,'checkbox ');   

      check1.value = check1_value;   

      var btn = w.add("button", {x:256, y:11, width:93,height:25}, "Aplay", { name: "ok"}); 

     

     btn.onClick = function ()

        { 

        check1_value = check1.value;

        if(check1.value){alert('enabled')}   

        else{alert('disabled')}   

        save_settings();

        w.close() 

        } 

w.show() 

function save_settings()

    {

    settings.open("w");

    settings.writeln("var check1_value = " + check1_value);

    settings.close();

    }

Translate
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
Contributor ,
Jul 26, 2018 Jul 26, 2018

I confess I figured this was not possible.

Great !!! It Works very well. You are a genius r-bin very knowledgeable.

THANK YOU!

Translate
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
Contributor ,
Jul 27, 2018 Jul 27, 2018

How interesting!

r-bin, Just a curiosity: Can this be used with radio buttons as the order I want it to be enabled in a situation where there are 4 radio buttons? If possible, could you show me a good example? Excuse me for getting involved in someone else's post.

Translate
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 ,
Jul 27, 2018 Jul 27, 2018

Nothing is different. Do the same by analogy.

var settings = new File(app.preferencesFolder + "/{06704d4d-4e32-4c26-87ab-78d674f1eeab}.dat") 

if (settings.exists) $.evalFile(settings); 

var rb1_value; if (rb1_value == undefined) rb1_value = true;  

var rb2_value; if (rb2_value == undefined) rb2_value = false;

var rb3_value; if (rb3_value == undefined) rb3_value = false;

var rb4_value; if (rb4_value == undefined) rb4_value = false;

var w = new Window("dialog");  

w.preferredSize.width = 200;

var rb1 = w.add("radiobutton", undefined, "1");

rb1.value = rb1_value;

var rb2 = w.add("radiobutton", undefined, "2");

rb2.value = rb2_value;

var rb3 = w.add("radiobutton", undefined, "3");

rb3.value = rb3_value;

var rb4 = w.add("radiobutton", undefined, "4");

rb4.value = rb4_value;

var b1 = w.add("button",  undefined, "OK");   

       

b1.onClick = function () 

    {   

    rb1_value = rb1.value; 

    rb2_value = rb2.value; 

    rb3_value = rb3.value; 

    rb4_value = rb4.value; 

    save_settings(); 

    w.close()   

    }   

 

w.show()   

 

function save_settings() 

    { 

    settings.open("w"); 

    settings.writeln("var rb1_value = " + rb1_value); 

    settings.writeln("var rb2_value = " + rb2_value); 

    settings.writeln("var rb3_value = " + rb3_value); 

    settings.writeln("var rb4_value = " + rb4_value); 

    settings.close(); 

    } 

Translate
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
Contributor ,
Jul 27, 2018 Jul 27, 2018
LATEST

Got it! You are too kind. A good example, now is simple to understand.

Thank you r-bin this will be very helpful to me.

Translate
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