Hello Kirupa!
I want to make a custom text select in Input texts when you double click it. I tried setting a function to the double click event of the text field with my selection rule. That worked, but it is very slow, because, first the Flash do the default selection, then it applies my rule.
So I went to AS3 Docs and found this text at flash.events.Event description:[INDENT][COLOR=Indigo]"[…]For example, the doubleClick event has an associated default behavior that highlights the word under the mouse pointer at the time of the event. Your event listener can cancel this behavior by calling the [FONT=Courier New]preventDefault()[/FONT] method.[…]"[/COLOR]
[/INDENT]I used [FONT=Courier New]preventDefault()[/FONT] in my function handle and it continues to select the text.
Any hints?
Here is the [FONT=Courier New]preventDefault()[/FONT] link:
http://livedocs.macromedia.com/flex/2/langref/flash/events/Event.html#preventDefault()
Here is the code:
**package** {
**import** flash.display.Sprite;
**import** flash.events.MouseEvent;
**import** flash.text.TextField;
**public class** Test **extends** Sprite {
**private var** t:TextField;
**public function** Test() {
t = **new** TextField();
t.type = [COLOR=Red]"input"[/COLOR];
t.doubleClickEnabled = **true**;
t.addEventListener(MouseEvent.DOUBLE_CLICK, handleDblClick);
addChild(t);
}
**private function** handleDblClick(e:MouseEvent):void {
e.preventDefault();
t.setSelection( 0, 1 );
}
}
}
Try typing some text to it and double click the text.
Thanks,
Ian Liu.