Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 97529

Re: Control the visibility of buttons

$
0
0

var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Hide test", undefined, {resizeable:true});

                    myPanel.spacing = 1;

                    myPanel.margins = [0,0,0,0];

                    myPanel.preferredSize = [30,0];

A dockable panel does not have a preferredSize attribute. The panel base size can only be initially determined through the layout method (used near the end of the code). To make a specific window size you would need to define a floating window differently, and it would no longer be a dockable one. If you are wanting the buttons to be 30 pixels wide, then you need to define that in the resource string instead.

 

how i can save the users input on the checkboxes (Like when it is checked, it stays checked until the user uncheck it).

Since the checkboxes are recreated fresh every time you click the settings button, you will need to save the value to the preferences. When you click the settings button you would need to add additional code to find and retrieve the preference for the check box.

 

You will need to make a variable and an if statement for each of the checkboxes like this:

var hideOnePrefCheck = app.settings.haveSetting("myScriptPrefs", "hideone");

if(hideOnePrefCheck == true && app.settings.getSetting("myScriptPrefs", "hideone") == "true"){

     hideOne.value = true;

}

 

You will also need to add the saveSetting method for each onClick like this:

hideOne.onClick = function(){

     switch(hideOne.value){

          case true:

               app.settings.saveSetting("myScriptPrefs", "hideone", "true");

               myButton1.visible = false;

               myButton1.preferredSize = [0,0];

               myPanel.layout.layout(true);

               break;

          default:

               app.settings.saveSetting("myScriptPrefs", "hideone", "false");

               myButton1.visible = true;

               break;

          }

}

 

It breaks down like this:

app.settings.haveSetting("myScriptPrefs", "hideone");          //Checks for a pref

app.settings.getSetting("myScriptPrefs", "hideone");          //Gets pref value

app.settings.saveSetting("myScriptPrefs", "hideone", "true");//Saves a pref

 

//"myScriptPrefs"     (preference category)

//"hideone"               (preference item)

//"true"                    (preference value as a string)


Viewing all articles
Browse latest Browse all 97529

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>