Copy link to clipboard
Copied
Dear all,
as you can see in the photo below,
I'd like to automatically adjust the height and weight of the text box according to the choice of radio buttons.
at 100%, the text contained in the text field is: "the equipment can be used" . for example
at 50%, the text contained in the text field is: "The product can be used safely (provided that the above defects and observations are taken into account)".
at 0% the text is: "the equipment must be repaired".
is it possible to automatically adjust the height and weight of the text field?
the test to be displayed is already predefined, so the user doesn't enter any information, just select between 100%, 50% and 0%.
Thanks in advance.
Copy link to clipboard
Copied
Since you have predefined text it's possible using rect, it's best to set up field height/width manually for each text and get rect for each text, then you can use that in your script to set height/width for each text.
To get rect of a field, open console CTRL+J (on Windows) and let's say field name is "Text1" paste this into console and press enter:
this.getField("Text1").rect;
you should get a bunch of numbers now, those are rect points for your current field position, copy and paste those numbers somewhere for now and repeat process for all 3 texts.
Now use those numbers in your script like this:
var rb = this.getField("Group1").valueAsString;
var rYes = [235.45343017578125,742.2980346679688,420.0910949707031,719.7980346679688];
// 100%
if(rb === "Yes"){
event.target.display = display.visible;
event.value = "the equipment can be used ";
event.target.fillColor = color.green;
event.target.rect = rYes;}
Copy link to clipboard
Copied
It's possible to set height and width of field using 'rect' property.
Copy link to clipboard
Copied
Upadte : below, the code I use without automatic adjustment.
var rb = this.getField("Group1").valueAsString;
// 100%
if(rb === "Yes"){
event.target.display = display.visible;
event.value = "the equipment can be used ";
event.target.fillColor = color.green;}
// 50%
else if(rb === "Yes1"){
event.target.display = display.visible;
event.value = "The product can be used safely (provided that the above defects and observations are taken into account)";
event.target.fillColor = color.yellow;}
// 0%
else if(rb === "Yes2"){
event.target.display = display.visible;
event.value = "the equipment must be repaired";
event.target.fillColor = color.red;}
else {
event.target.display = display.hidden;}
Copy link to clipboard
Copied
What exactly you're trying to do with text field?
Copy link to clipboard
Copied
@Nesa Nurani as you can see in the screenshot below,
depending on the percentage selected, a text is displayed in the text Field. But,
I'd like the length and width to adjust automatically (if possible) according to the predefined text to be displayed.
here's the code I'm currently using to display the information.
var rb = this.getField("Group1").valueAsString;
// 100%
if(rb === "Yes"){
event.target.display = display.visible;
event.value = "the equipment can be used ";
event.target.fillColor = color.green;}
// 50%
else if(rb === "Yes1"){
event.target.display = display.visible;
event.value = "The product can be used safely (provided that the above defects and observations are taken into account)";
event.target.fillColor = color.yellow;}
// 0%
else if(rb === "Yes2"){
event.target.display = display.visible;
event.value = "the equipment must be repaired";
event.target.fillColor = color.red;}
else {
event.target.display = display.hidden;}
Copy link to clipboard
Copied
Since you have predefined text it's possible using rect, it's best to set up field height/width manually for each text and get rect for each text, then you can use that in your script to set height/width for each text.
To get rect of a field, open console CTRL+J (on Windows) and let's say field name is "Text1" paste this into console and press enter:
this.getField("Text1").rect;
you should get a bunch of numbers now, those are rect points for your current field position, copy and paste those numbers somewhere for now and repeat process for all 3 texts.
Now use those numbers in your script like this:
var rb = this.getField("Group1").valueAsString;
var rYes = [235.45343017578125,742.2980346679688,420.0910949707031,719.7980346679688];
// 100%
if(rb === "Yes"){
event.target.display = display.visible;
event.value = "the equipment can be used ";
event.target.fillColor = color.green;
event.target.rect = rYes;}
Copy link to clipboard
Copied
@Nesa Nurani thanks for your help,
it works fine
Find more inspiration, events, and resources on the new Adobe Community
Explore Now