Prevent the Flex TextArea from intercepting the mouse wheel event
Posted 9 Dec 2008 by Akinwale Ariwodola
Life has just taught me a lesson. Do not encounter problems that people have rarely experienced.I have a story to tell. I had a TextArea in a VBox which prevented the container from vertically scrolling if the mouse cursor was over the TextArea. The vertical scrolling worked fine when the mouse cursor was over other parts of the container. After spending several hours on Google looking for how to fix this and coming across only a couple of solutions (this and this) which did not work, or maybe my Google fu just plain sucks, I decided to roll my own.
After doing a bit of digging, following the approach in the second solution, I discovered that the TextArea has a mouseWheelHandler event handler defined. All I had to do was remove the event listener like so:
package
{
import mx.controls.TextArea;
public class MultilineText extends TextArea
{
override protected function createChildren():void
{
super.createChildren();
removeEventListener(MouseEvent.MOUSE_WHEEL, mouseWheelHandler);
}
}
}
Problem Solved. This occurred in an AIR app, though. I haven't bothered to test this in Flash Player and I really don't feel like it. Hopefully, this helps someone who encounters something like this in the future.


Comments (12)
/>
##################################
public function setScroll(event:Event):void{
event.target.verticalScrollPosition=0;
}
]]>
Put this into the TextArea attributes
###################
scroll="setScroll(event);"
###################
public function setScroll(event:Event):void{
event.target.verticalScrollPosition=0;
}
Thanks.
import flash.events.MouseEvent;
I had the same problem and had to word it a few different ways to Google search to find this solution. It's been a big help.
- Trevor
had to add an import statement for the mouse event in Flex