How to prevent a specific key such as backspace key functioning from TextField editable field, preventDefault does not seem to work:
public function handleEvents(evt:KeyboardEvent):void {
if (evt.type == KeyboardEvent.KEY_UP) {
if (evt.keyCode==8){
evt.preventDefault () ;
}
}
From stackoverflow
-
Try adding evt.stopImmediatePropagation()
Goran : Did you add both prevent defaul and stop propagation? Also try adding the event handler on stageTom : not working: TextField() gets the event 1st, but I also added same listener to stage, there was no difference with both preventDefault and stopImmediate.. -
I recommend listening for the KEY_DOWN event if anything, but likely that won't work either. IIRC these type of events are a bit special and you can't really stop them. What I suspect you need to do is to store a copy of the text and whenever you detect a change you don't like just set it back to your stored version.
0 comments:
Post a Comment