Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-19-2010, 01:06 PM   #1
marcos
Registered User
 
Join Date: Jan 2010
Posts: 2
Default overriding default event listener?

hello

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.
marcos is offline   Reply With Quote
Old 01-19-2010, 02:56 PM   #2
Sophie_cordier
Registered User
 
Join Date: Dec 2009
Posts: 12
Default

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
event.stopPropagation();
}

Sophie
Sophie_cordier is offline   Reply With Quote
Old 01-19-2010, 02:57 PM   #3
box86rowh
FLEX AND FLASH ARE COOL
 
Join Date: Oct 2005
Posts: 794
Default

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.
box86rowh is offline   Reply With Quote
Old 01-19-2010, 11:15 PM   #4
marcos
Registered User
 
Join Date: Jan 2010
Posts: 2
Default

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.

ActionScript Code:
package embed {     import mx.controls.Text;     import mx.controls.TextArea;     public class EText extends TextArea     {         public function EText()         {             super();         }                  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 .
marcos is offline   Reply With Quote
Old 01-20-2010, 02:37 AM   #5
box86rowh
FLEX AND FLASH ARE COOL
 
Join Date: Oct 2005
Posts: 794
Default

you can also set focusEnabled to false to disable this
box86rowh is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:23 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.