Skip to main content
Łukasz Markowski
Inspiring
November 9, 2015
Answered

"Live" Dialog box

  • November 9, 2015
  • 1 reply
  • 457 views

Hello,

I have a question about dialog box.

I have a rectangle in artboard with dimensions 50x50mm.

When I press button "Pobierz" I would like get object width in text box.

There is any way to do this?

This is my initial script.

var myWindow = new Window ("dialog", "Dane do impozycji");

myWindow.orientation = "column";

//myWindow.alignChildren = ['', 'center'];

myWindow.panel1 = myWindow.add('panel', undefined, '');

  myWindow.panel1.orientation = 'column';

  

myWindow.przyciskOK = myWindow.add('button', undefined, 'Wykonaj', {name:'ok'});

  myWindow.przyciskOK.orientation = 'row';

  

myWindow.panel1.add ("statictext", undefined, "Szerokość etykiety:");

var myText = myWindow.panel1.add ('edittext {text: 0, justify: "center"}');

myText.characters = 5;

myText.active = true

myText.alignment = ["centre","centre"];

var pobranie = myWindow.add('button',undefined,'Pobierz');

pobranie.onClick = function() {

//THERE SHOULD BE SOME FUNCTION TO GET VALUE IN TEXT

    }

myWindow.show ();

This topic has been closed for replies.
Correct answer Vinicius Baptista

Dear Markowski, this is a simple way to do this:

Note: Select a object before perform this script.

pobranie.onClick = function() {

    myText.text = (app.activeDocument.selection[0].width/2.8346456767).toFixed (2);

    //If Don`t want convert to MM, just use app.activeDocument.selection[0].width

    }

Try, if doubts, please contact us.

Have fun, Greetings,

-Vinícius Baptista

1 reply

Vinicius Baptista
Vinicius BaptistaCorrect answer
Inspiring
November 9, 2015

Dear Markowski, this is a simple way to do this:

Note: Select a object before perform this script.

pobranie.onClick = function() {

    myText.text = (app.activeDocument.selection[0].width/2.8346456767).toFixed (2);

    //If Don`t want convert to MM, just use app.activeDocument.selection[0].width

    }

Try, if doubts, please contact us.

Have fun, Greetings,

-Vinícius Baptista

Łukasz Markowski
Inspiring
November 9, 2015

Hello Vinicius,

Thank you for answer, it works. I'm grateful to you.

Vinicius Baptista
Inspiring
November 9, 2015

No problem man, I'm glad to help you.