Copy link to clipboard
Copied
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();
According to the javascript tools guide "Justification only works if the value is set on creation, using a resource specification or creation parameters."
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
...Copy link to clipboard
Copied
According to the javascript tools guide "Justification only works if the value is set on creation, using a resource specification or creation parameters."
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.
Copy link to clipboard
Copied
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.