I don't want to allow linewise scrolling in textArea in noneditable mode
I d开发者_高级运维on't want to allow linewise scrolling(means through arrow key) in textArea in noneditable mode
Without having time to actually write the code, here's what I would do conceptually:
If your
TextArea
is not editable, add anEventListener
that checks to see if theTextArea
currently has focus. When theTextArea
has the focus yourEventListener
should create anotherEventListener
that looks for a keyboard event.In your keyboard event
EventListener
, check to see if the key that was pressed was an arrow key. If it was an arrow key, trap the event and do nothing.When the
TextArea
loses focus, remove theEventListener
that checks for the arrow keys being pressed.
I hope this helps!
Edit: When a key is pressed on the keyboard, it has a specific keyCode Flex can use to tell which key was pressed. The arrow keys are 37 - 40.
To take from an example (from the Adobe Live Docs):
<mx:Script>
<![CDATA[
private function initApp():void {
myTextArea.addEventListener(KeyboardEvent.KEY_UP, keyHandler);
}
private function keyHandler(event:KeyboardEvent):void {
if(event.keyCode >= 37 && event.keyCode <= 40)
{
event.stopImmediatePropagation();
}
}
]]>
</mx:Script>
精彩评论