Reputation: 14162
I have a TextArea that I want to give a fixed height to, and have scrollbars appear if the text overflows that height.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:TextArea
height="34"
text="Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7"/>
</mx:Application>
However, if I give it a height, no scrollbars appear (though I can scroll the text with the mousewheel or by selecting text). Even forcing scrollbars to always appear using verticalScrollPolicy="on"
doesn't work.
Upvotes: 0
Views: 574
Reputation: 563
If you look at the source for TextArea, you can see that the verticalScrollPolicy is hardcoded to be OFF if less than or equal to 40 pixels:
override public function get verticalScrollPolicy():String
{
return height <= 40 ? ScrollPolicy.OFF : _verticalScrollPolicy;
}
You have a few options:
Set the TextArea height to 41 or greater
Create a custom control that inherits mx TextArea and override this method:
override public function get verticalScrollPolicy():String
{
return _verticalScrollPolicy;
}
Use the Spark TextArea instead and use the property heightInLines
I found the answer in the following thread: http://tech.groups.yahoo.com/group/flexcoders/message/112148
Upvotes: 1