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

To create and interact with user interface elements

Community Beginner ,
Dec 20, 2022 Dec 20, 2022

Copy link to clipboard

Copied


Greetings to everyone!
When I call a dialog, I need to pass it the value of the text (StaticText). EditText would like the text to be typed from the center (justify: "center").

I wrote the code for such a window in two versions.
in the first case, I cannot assign a value (StaticText).
In the second version, I cannot make the text in the EditText field aligned in the center.

How to make any of the options work?

 

 

var myTxt = 'figny';

// version1
var w = new Window( "dialog { \
    orientation: 'row', \
    st: StaticText {text:myTxt}, \
    pb: Button { text: 'OK' }, \
    et: EditText { characters:15, justify:'center' } \
    }");
w.show(); 

// version2
win = new Window('dialog');
win.orientation = 'row';
win.st = win.add('statictext', undefined, myTxt);
win.bt = win.add('button', undefined, 'ok');
win.et = win.add('edittext');
win.et.characters = 15;
win.et.justify = 'center';
win.show();

 

TOPICS
Scripting

Views

581

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 2 Correct answers

Community Expert , Dec 20, 2022 Dec 20, 2022

Try following

var myTxt = 'figny';

// version1
var w = new Window("dialog { \
    orientation: 'row', \
    st: StaticText {text:'" + myTxt + "'},\
    pb: Button { text: 'OK' }, \
    et: EditText { characters:15, justify:'center' } \
    }");
w.show();

// version2
win = new Window('dialog');
win.orientation = 'row';
win.st = win.add('statictext', undefined, myTxt);
win.bt = win.add('button', undefined, 'ok');
win.et = win.add('edittext {text: "", characters: 15, justify: "center", active: tr
...

Votes

Translate

Translate
Community Expert , Dec 30, 2022 Dec 30, 2022

these are all the different ways of using the name property

var win = new Window( 'dialog' );
chInk_10 = win.add( 'checkbox {text:"ink_10", visible:false, properties:{name:"ten"}}' );

// access element by finding the element
var check10 = win.findElement("ten"); // this also works with a name like 10
check10.visible = true;

alert("or by chaining its name: \n\nVisible: " + win.ten.visible); // this won't work with a numeric name, variable names should not start with numbers in general

alert("o
...

Votes

Translate

Translate
Adobe
Community Beginner ,
Dec 20, 2022 Dec 20, 2022

Copy link to clipboard

Copied

Fixed the first option. it works

var myTxt = 'figny';


var w = new Window( "dialog { \
    orientation: 'row', \
    des: StaticText { characters:5 }, \
    pb: Button { text: 'OK' }, \
    et: EditText { characters:15, justify:'center' } \
    }");
w.des.text = myTxt;
w.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
Community Expert ,
Dec 20, 2022 Dec 20, 2022

Copy link to clipboard

Copied

Try following

var myTxt = 'figny';

// version1
var w = new Window("dialog { \
    orientation: 'row', \
    st: StaticText {text:'" + myTxt + "'},\
    pb: Button { text: 'OK' }, \
    et: EditText { characters:15, justify:'center' } \
    }");
w.show();

// version2
win = new Window('dialog');
win.orientation = 'row';
win.st = win.add('statictext', undefined, myTxt);
win.bt = win.add('button', undefined, 'ok');
win.et = win.add('edittext {text: "", characters: 15, justify: "center", active: true}');
win.show();
Best regards

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
Community Beginner ,
Dec 20, 2022 Dec 20, 2022

Copy link to clipboard

Copied

Great!!!
I still need to know a lot about script writing rules

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
Community Beginner ,
Dec 29, 2022 Dec 29, 2022

Copy link to clipboard

Copied

Hi everyone!
I will continue to ask questions in this topic so as not to create a new one...
How do I access a management object by its unique name defined in its properties?
I would like to use a variable as a name when accessing.
For example, I create a checkbox with the unique name 10.

var win = new Window( 'dialog' );
chInk_10 = win.add( 'checkbox {text:"ink_10", visible:false, properties:{name:10}}' );

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
Community Expert ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

these are all the different ways of using the name property

var win = new Window( 'dialog' );
chInk_10 = win.add( 'checkbox {text:"ink_10", visible:false, properties:{name:"ten"}}' );

// access element by finding the element
var check10 = win.findElement("ten"); // this also works with a name like 10
check10.visible = true;

alert("or by chaining its name: \n\nVisible: " + win.ten.visible); // this won't work with a numeric name, variable names should not start with numbers in general

alert("or by targeting the parent's children name: \n\nVisible: " + win.children["ten"].visible); // name:10 will also work here

win.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
Community Beginner ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

thank you for your time on my problem.
I had to organize a search for checkboxes by name. And I decided this as follows: I added letters to the number in the name.

As I understand, if you use only digits in the name, then the value of the variable converted String() cannot be substituted as an argument in the function findElement()

var win = new Window( 'dialog' );
chInk_1 = win.add( 'checkbox {text:"ink_10", properties:{name:"ch1"}}' );
// many more checkboxes
chInk_10 = win.add( 'checkbox {text:"ink_10", properties:{name:"ch10"}}' );

for (i = 1; i < 2; i++ ) { // loop, as an example of a variable change
var nameCh = 'ch' + String(i);
win.findElement(nameCh).value = true;
}
win.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
Guide ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

Hi @CarlosCanto.  Where did you get findElement() from?  It's not in the old tool's guide I have. 

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
Community Expert ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

quote

Hi @CarlosCanto.  Where did you get findElement() from?  It's not in the old tool's guide I have. 


By @femkeblanco

 

 

Hi @femkeblanco 

https://extendscript.docsforadobe.dev/user-interface-tools/scriptui-programming-model.html#accessing...

 

Have fun

😉

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
Community Expert ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

Hi @femkeblanco it's in the last Tools Guide, I think for 2017? I think all Tool Guides are just copies of the previous doc, I don't think they had any updates anyway. It's on pages 66-67 "Creation Properties", "Accessing Child Elements"

 

I'm not sure if it's always been in the Tools Guide, I remembered I had used the findElement() before so I just searched my scripts library, but then I went to the Guide to provide a more concise answer

 

What version do you have?

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
Guide ,
Dec 31, 2022 Dec 31, 2022

Copy link to clipboard

Copied

Thanks @CarlosCanto and @pixxxelschubser.  I have been using the CS3 guide, which I presume came with CS6 (2012).  I didn't think it was ever updated.  The present guide seems to be based on the 2013 guide.  It has the same exact paragraph, except with to more lines introducing findElement(). 

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
Community Expert ,
Dec 31, 2022 Dec 31, 2022

Copy link to clipboard

Copied

LATEST

I fetched the CS5 Tools Guide, it's from 2010, findElement is there in the same spot as the current guide pages 67 and 120.

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
Community Expert ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

 

 

Hi everyone!
I will continue to ask questions in this topic so as not to create a new one …


By @Dmitriy27445167miri

 

Hello @Dmitriy27445167miri 
even though it may seem advantageous to you at the moment - it is not.

 

The forum works best if you create a separate thread for each question, give it a meaningful title - and in the best case get one or even more correct answers to exactly that question. These answers should then also be marked as correct.

 

This way you and all other future questioners can use the forum search and easily find your question and the corresponding correct answers. Collective topics quickly become confusing. Several correct but possibly completely unrelated answers in a single topic that stretches over many pages is unfortunately of no use to anyone.

 

In future, please create a new topic with a meaningful title for new questions. If you don't know it yet, you can easily find all your topics again. Click on your profile picture (top right of each page) and then in the drop-down menu on: "My profile".

 

Have fun in the forum.

Your friendly forum moderator.

😉

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
Community Beginner ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

Yes, I have already understood my mistake. Excuse me as a newcomer to the forum.
I will not do this again!

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
Community Expert ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

That's not a problem at all. We were all newcomers here once.
😉

 

 

Question:
Could @CarlosCanto 's answer help solve your second problem?

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
Community Beginner ,
Dec 31, 2022 Dec 31, 2022

Copy link to clipboard

Copied

quote

That's not a problem at all. We were all newcomers here once.
😉

 

 

Question:
Could @CarlosCanto 's answer help solve your second problem?


By @pixxxelschubser

yes of course.

 

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
Community Expert ,
Dec 30, 2022 Dec 30, 2022

Copy link to clipboard

Copied

quote

Yes, I have already understood my mistake. Excuse me as a newcomer to the forum.
I will not do this again!


By @Dmitriy27445167miri

 

I agree with @pixxxelschubser, a new thread would have been better for future use, but not creating one is not that big of a deal, don't worry about it.

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