Flex的TextArea中 如何在一定条件下阻止删除动作
例如 TextArea中有文本如下
标题> 1234567
此例中1234567可以被删除
但是"标题>"是不可以被删除掉的
求解, 如何实现?
最好不要是删除">"之后再补回来这种动作.
(**这个是治标不治本的办法. 因为BackSpace是可以连续触发效果的
如果按住不放, 会删除很多内容, 当抬起的之后才会补回来一个">")
求解决实际问题的方法!!! 急啊... 高手们快来吧
[解决办法]
试试这个 是不是你想要的效果:
自定义MyTextArea组件
package{ import flash.display.DisplayObject; import mx.containers.Canvas; import mx.controls.Text; import mx.controls.TextArea; public class MyTextArea extends TextArea { private var _title:String = ""; private var titleChanged:Boolean = false; private var titleField:Text; public function MyTextArea() { super(); } override protected function createChildren():void { super.createChildren(); createTitleField(); } override protected function commitProperties():void { super.commitProperties(); if (titleChanged && titleField != null) { titleField.text = title; } } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth,unscaledHeight); titleField.x = textField.x; titleField.y = textField.y; titleField.width = this.width; titleField.height = 15; textField.height = this.height - 100; textField.move(textField.x, textField.y + titleField.height); } private function createTitleField():void { if (!titleField) { titleChanged = true; titleField = new Text(); addChildAt(DisplayObject(titleField), 0); } } public function set title(value:String):void { if (_title != value) { titleChanged = true; _title = value; invalidateProperties(); } } public function get title():String { return _title; } }}