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

Display proportional value in the text box

Engaged ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

Hello everyone!
I am thinking of creating a script that can resize the sizes of several layers in batch through a small and simple dialog box that contains some elements such as two text boxes, one corresponding to the width value and the other to the height value, however I can't find a way to calculate the percentage of the value added in the height or width of the text boxes so that I can display the proportional value in the opposite text box.
See the Illustration for a better understanding:

0003.gif

example script

dlg = new Window("dialog"); dlg.text = "Dialog";
dlg.orientation = "row"; dlg.alignChildren = ["center","center"];
dlg.spacing = 10; dlg.margins = 16;

et1 = dlg.add('edittext {properties: {name: "et1"}}');
et1.text = "10";

st1 = dlg.add("statictext", undefined, undefined, {name: "st1"});
st1.text = "cm x";

et2 = dlg.add('edittext {properties: {name: "et2"}}');
et2.text = "15";

st2 = dlg.add("statictext", undefined, undefined, {name: "st2"});
st2.text = "cm ";

et1.onChanging = function(){ et2.text = "value"};

dlg.show();

Detail! The script will have the option to maintain or not the proper proportions of width and height.

Grateful for the help!

 
TOPICS
Actions and scripting

Views

300

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 , Dec 15, 2020 Dec 15, 2020

Try this

 

dlg = new Window("dialog"); dlg.text = "Dialog";
dlg.orientation = "row"; dlg.alignChildren = ["center","center"];
dlg.spacing = 10; dlg.margins = 16;

et1 = dlg.add('edittext {properties: {name: "et1"}}');
et1.text = "10";

st1 = dlg.add("statictext", undefined, undefined, {name: "st1"});
st1.text = "cm x";

et2 = dlg.add('edittext {properties: {name: "et2"}}');
et2.text = "15";

st2 = dlg.add("statictext", undefined, undefined, {name: "st2"});
st2.text = "cm ";

et1.onChanging = fun
...

Votes

Translate

Translate
Adobe
People's Champ ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

Try this

 

dlg = new Window("dialog"); dlg.text = "Dialog";
dlg.orientation = "row"; dlg.alignChildren = ["center","center"];
dlg.spacing = 10; dlg.margins = 16;

et1 = dlg.add('edittext {properties: {name: "et1"}}');
et1.text = "10";

st1 = dlg.add("statictext", undefined, undefined, {name: "st1"});
st1.text = "cm x";

et2 = dlg.add('edittext {properties: {name: "et2"}}');
et2.text = "15";

st2 = dlg.add("statictext", undefined, undefined, {name: "st2"});
st2.text = "cm ";

et1.onChanging = function(){ et2.text = Number(et1.text)*1.5};
et2.onChanging = function(){ et1.text = Number(et2.text)/1.5};

dlg.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
Engaged ,
Dec 15, 2020 Dec 15, 2020

Copy link to clipboard

Copied

LATEST

I tried it here and it worked perfectly wellr-bin . Thanks for sharing your knowledge.

 

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