View Full Version : overriding default event listener?

01-19-2010, 01:06 PM

just wanna know the way to disable the default mouseDown event on TextArea, thats it, no default reaction on mouse down.

textarea mouseDown modify the selectionBeginIndex and some other values i believe, it might be the focus not also the mouseDown but i would apprecaite anyone tel me the key to override those default listeners by an example.

i tried the preventDeafult() way, but with no success.

i think extending the TextArea is the way, but i can't figure how to do such a simple thing.

Thanx in advance.

01-19-2010, 02:56 PM
Hello Marcos,

Try add a mouseDown listener on your application that "catches" the event:
this.addEventListener(MouseEvent.MOUSE_DOWN, catchEvent, true);
In this way, the event will not be dispatched anymore (unless you want to).

private function catchEvent(event:MouseEvent):void {
if (event.target is TextArea) {
//put your code here


01-19-2010, 02:57 PM
can you change the mouseEnabled property to false?
also why disable the mousedown action? What are you trying to prevent? You can use the editable property to make it so you cant edit the text and selectionEnabled? or something like that to control whether the text can be highlighted.

01-19-2010, 11:15 PM
thnaks many Sophie_cordier, your method works but i discovered that clicking the scroll area and the buttons on scrolls give also another event.target so its not good to disable them all

box86rowh, tried all this allready but no avail, my problem was clicking on any spot on textarea change the Selection index even though the ediable and selectable are disabled.

but good news i found in easy way to solve all this textarea behaiver when click.

package embed
import mx.controls.Text;
import mx.controls.TextArea;

public class EText extends TextArea
public function EText()

override public function setFocus():void{



it was setFocus method that causing this, i tried to digg on what this method do but its for TextField which i can't see the source afaik.

anyway thanks all for helping :).

01-20-2010, 02:37 AM
you can also set focusEnabled to false to disable this