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

Question about characters in statictext in dialog box!

Contributor ,
Nov 20, 2017 Nov 20, 2017

How do I get only 3 numbers, (maximum 2 numbers after the dot) in statictext?

#target photoshop 

var doc = activeDocument; 

app.preferences.rulerUnits = Units.CM; 

 

dlg = new Window('dialog','Final Width Size'); 

dlg.gp = dlg.add('group'); 

dlg.gp.stxt = dlg.gp.add('statictext',undefined,'Width Size'); 

dlg.gp.etxt = dlg.gp.add('statictext {text: "Centre", characters: 3, justify: "center"}');

dlg.btn = dlg.add('button',undefined,'Close'); 

  dlg.gp.etxt.text =(doc.width)*1; 

 

dlg.btn.onClick = function (){ 

    dlg.close(); 

    } 

 

dlg.show();

Screenshot_3.jpg

I thought that would solve:

('statictext {text: characters: 3}');

TOPICS
Actions and scripting
726
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

Guide , Nov 20, 2017 Nov 20, 2017

Try...

dlg.gp.etxt.text =(doc.width.value.toFixed(1));  

Translate
Adobe
Guide ,
Nov 20, 2017 Nov 20, 2017

Try...

dlg.gp.etxt.text =(doc.width.value.toFixed(1));  

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 ,
Nov 20, 2017 Nov 20, 2017

dlg.gp.etxt.text = doc.width.value.toFixed(2) + " " + doc.width.type;

upd.

was late )

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 ,
Nov 20, 2017 Nov 20, 2017
LATEST

Now it works like a marvel!

SuperMerlin, thank you for the tip!

r-bin,your suggestion also worked very well, it will be very important.

Thank you both for sharing your knowledge. I am very happy with the results.

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