0 Replies Latest reply on Jul 31, 2010 12:11 PM by Yalamber Tamot

    modify deleteSelectionState of InsertTextOperation of TextOperationEvent possible?

    Yalamber Tamot

      Hi,

       

      I have a spark textarea component listening to TextOperationEvent.CHANGING inside creationCompleteHandler.

       

      text_area.addEventListener(TextOperationEvent.CHANGING, textChangingHandler);

       

      What I want to do is when the user inputs "a" the InsertTextOperation text is changed to devanagari "अ" so the user effectively inputs "अ" by typing "a" on the keyboard. This is no problem and I get the result as expected using the code similar to below:

       

      protected function textChangingHandler(e:TextOperationEvent):void {

           if (e.operation is InsertTextOperation) {

                var flowInsert:InsertTextOperation = e.operation as InsertTextOperation;

                var current_char:String = flowInsert.text.charAt(0);

       

                if (current_char == "a") {

                     flowInsert.text = "अ";

                }

           }

      }

       

      Problem that I have been trying to figure out is next when the user again types "a", I want the text to change to "आ" replacing the previous "अ". Now, it looks like this can be achieved by using a variable to hold previous character typed, examine if it is "a", delete the previous "अ" using deleteSelectionState property of flowInsert(see above code) along with god knows what and, similarly(as above) replace the flowInsert.text with "आ".

       

      How can this be achieved? I have tried manipulating the deleteSelectionState without result please help!!! Your help is deeply appreciated.

       

      Thankyou,

       

      Yalamber Tamot