Expand my Community achievements bar.

Right-justify a field

Avatar

Level 3

I would like a text field to expand to the left when I type a long string into it. Right now it expands to the right. Is this possible? I tried using the paragraph controls and the anchor controls but no luck.

It is a price field that is near some other text so when a person types in a long string I need it to expand left.

Can anyone help?

6 Replies

Avatar

Level 3

Stumping the group, huh? Darn. Well I guess I will

have to come up with a different way.


Avatar

Former Community Member

I do not believe that XFA supports that type of growth at this time. In onlt does right to left.

Paul

Avatar

Level 3

I think I might have another way to do it. Can I set the location of the field on exit?

If I can, then I could always have the fields right corner return to the x y I tell it to. Which would do the trick.

Is this possible?

Avatar

Level 10

Oh, you are definitely onto something there - good bit of lateral thinking.

On exit you could find out the new width of the object:

var vNewWidth = this.w;

Then assign the x of the object as a function of the old x; the width of the page and vNewWidth.

John Brinkman has good examples on his blog.

I have a sample of moving objects based on the mouse x,y coordinates which may help (http://cookbooks.adobe.com/post_Moving_Objects_Around_a_Form-16519.html).

Good luck,

Niall

Avatar

Level 2

Hi,

I have been trying to do something similar and with the help of Niall's wonderful resources, in particular "Expanding textfields maintaining horizontal position" - http://www.assuredynamics.com/index.php/portfolio/expanding-textfields-maintaining-horizontal-positi... - I managed to work something out. However it only works in quirky way and I can't figure out why. Basically I have a text field that expands or contracts according to how long the entry is. I have set the text field to "Expand to fit". What I am trying to do is keep the text field on the right-hand side of the page but within the page limits of course. So when a long entry is made into the text field it should move to the left to accommodate the long entry. Here is the script I have used (JavaScript, exit event, ES3):

===================================

form1.#pageSet[0].TitlePage.DocNum::exit - (JavaScript, client)

//check to see if text field is empty. If empty do not want field to change at all.
if  (this.rawValue != null)

//sets maximum width to empty to allow text field to resize when the entry is shorter than the space allowed
{this.maxW = "";

//get width of text field
var vNewWidth = xfa.layout.w(this, "mm");

//enter width of page
var vPageWidth = "203.65";

//calculate the x positions of the text field after an entry has been made
var vMeasure = vPageWidth - vNewWidth;

//set the x coordinate of the field
this.x = (vMeasure + "mm").toString();}

//resets the text field position if the entry is deleted
else {
this.x = "157.444mm";
this.w = "45.662mm"}

==================================================================

When I enter a value and exit the text field it resizes but does not reposition. If I click back in the text field and then exit it will then reposition. Why isn't this doing it all (resizing and repositioning) the first time around? What am I missing?

Thanks,

Greig