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

change justify editText with click

Community Beginner ,
May 16, 2021 May 16, 2021

I want to change the justify of the editText, but it does not work.

my code is:

 

var win = (this instanceof Panel) ? this : new Window("palette", "myScript", undefined, {resizeable:false});
var group=win.add('group');
group.orientation="column";
var edt = group.add('edittext {preferredSize: [220, 100], properties: {multiline: true},justify: "right"}');
var btn = group.add("button",undefined,"change justify");
btn.onClick=function()
{
edt.justify="left";
}
win.show();

 

TOPICS
Error or problem , How to , Scripting
511
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

Enthusiast , May 16, 2021 May 16, 2021

According to the javascript tools guide "Justification only works if the value is set on creation, using a resource specification or creation parameters."

https://extendscript.docsforadobe.dev/user-interface-tools/control-objects.html?highlight=justify#justify

 

So it's not surprising it can't be changed later. But when I test your code I'm not even getting right justification unless I set it to multiline:false, so those two options may not work together. You didn't say if you encountered that issu

...
Translate
Enthusiast ,
May 16, 2021 May 16, 2021

According to the javascript tools guide "Justification only works if the value is set on creation, using a resource specification or creation parameters."

https://extendscript.docsforadobe.dev/user-interface-tools/control-objects.html?highlight=justify#ju...

 

So it's not surprising it can't be changed later. But when I test your code I'm not even getting right justification unless I set it to multiline:false, so those two options may not work together. You didn't say if you encountered that issue, just that it 'does not work'.

 

If it was just a case of not being able to switch justification then I'd think you could fairly easily create a group with orientation 'stack' which would let you put multiple EditText in the same location, one for each justification, then switch visibility between them when you press the button. Then you'd just need something that filled in the text contents of the invisible one to that of the visible one when you make the switch.

 

But if like me you're not even getting right justification when multiline:true then that might be a dealbreaker anyway.

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
Community Beginner ,
May 16, 2021 May 16, 2021
LATEST

This is the best solution. Thank you for your help

 

If it was just a case of not being able to switch justification then I'd think you could fairly easily create a group with orientation 'stack' which would let you put multiple EditText in the same location, one for each justification, then switch visibility between them when you press the button. Then you'd just need something that filled in the text contents of the invisible one to that of the visible one when you make the switch.

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