My approach is to simply reject any change that would exceed the maxLines
setting. 

The following is presented sans the requisite class structure. 
Create a component that extends TextArea, then:  

var tf:TextField = TextField(this.textField);
var maxLines:uint = 5; // however many lines (getter/setter)
var storedInput:String = "";

private function onChange(event:Event):void
{
            if (tf.numLines > maxLines)
            {
                        tf.text = storedInput;
            }else{
                // Handle editable TextArea bugs
                            storedInput = tf.text;
                 } 
}

Issues: 
There is a bug in the TextArea component (editable="true") where any given
line will fail to wrap so long as the last character in the line is a space
(also, the insertion cursor disappears beyond the right edge of the field.)
But this can be managed. 
Using htmlText just makes a mess (the insertion cursor has a mind of its
own.)  
Regards, 

-Keith 
http://keithreinfeld.home.comcast.net
<http://keithreinfeld.home.comcast.net/> 
 

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Gordon Smith
Sent: Wednesday, December 03, 2008 7:27 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Flex TextArea Limited by number of lines.

This hasn't been a common request. What is your use case for allowing a user
to type up to, say, three lines but no more? Most UIs I've seen limit the
number of characters you can type, not the number of lines.
 
I think you have two choices: use the 'textInput' event to limit the amount
of text that goes in, or use the 'change' event to remove excess text that
has already gone in.
 
Which are you trying, and what problems are you running into?
 
Gordon Smith
Adobe Flex SDK Team
 
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of tchredeemed
Sent: Wednesday, December 03, 2008 7:09 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Flex TextArea Limited by number of lines.
 
Has anyone ever done this? Seen any tutorials on this? It seems that a
good amount of people would want something like this.

I keep running into issues with it, and it is very frustrating!
 

<<attachment: winmail.dat>>

Reply via email to