PDA

View Full Version : Auto sizing text fields


antun
02-04-2003, 04:55 PM
If you have text fields that will accept data, but you don't know how much text there will be (e.g. it gets set at runtime, from a script or by datapaths), it can be frustrating that the text gets clipped.

Here's a simple fix:-


<class name="resizetext" extends="text">
<method event="ontext">
this.setWidth( this.getTextWidth() );
</method>
</class>


Our custom resizetext class will stretch every time text is set to it.

However, be warned that this is expensive (which is why we didn't set this as default).

Enjoy!

hqm
02-04-2003, 05:26 PM
Actually, as of the DR release, you can say

<text resize="true">

and get the same effect.

You can also call text.setResize(true) from script.

arina
12-02-2004, 02:31 AM
Originally posted by antun

<class name="resizetext" extends="text">
<method event="ontext">
this.setWidth( this.getTextWidth() );
</method>
</class>




Could we do it with the height too?


Thanks

P.S. As I've understood from the LZX Reference, this construction wouldn't work:

<view height="${this.measureHeight()}">
...
content
...
</view>

???

antun
12-20-2004, 04:03 PM
If you don't set the height on the view or a contained text field, it should just stretch vertically as needed.

-Antun