2 Replies Latest reply: Jun 21, 2013 9:58 AM by saisri2k2 RSS

    Adobe flex copy paste htmlText into a text area

    saisri2k2 Community Member

      I've a textArea1, i'm copying htmlText from a differant textArea2 to the current text area, it bring the formatting of the textArea2, that is ok, when I clear the textArea1 text, when I start typing, i still get the same format of the textArea2, how do i know what was pasted into the textArea? i've tried paste event, it did not trigger any thing.

      What i'm trying to acheive is, try to find out what was pasted here, if the style of the text that is pasted is differant, then try to update the styles to the original. HOw to acheive this?

      Thanks.

        • 1. Re: Adobe flex copy paste htmlText into a text area
          hanchan07

          The TextArea has a changing event, the event type is a TextOperationEvent.

          The event has a property called operation.  This operation can be many things, like an InsertTextOperation if they are typing, or a PasteOperation if they are pasting.

          The operation also has a textflow property on it as well, but in this case the PasteOperation has a property called textScrap, and this has a textFlow of the text that is being pasted in.  So you should have access to any styles coming in with the text.

           

          Just a simple code snippet. 

           

          private function handler_textChange(event:TextOperationEvent):void

          {

               //see if action was cause of a paste

               if(event.operation is PasteOperation)

               {

                    //do what you need with the text flow object.

                    (event.operation as PasteOperation).textScrap.textFlow ........

               }

          }

           

          Hope that helps out.

          • 2. Re: Adobe flex copy paste htmlText into a text area
            saisri2k2 Community Member

            Thanks.

             

            I found the solution, when we copy paste. instead of resetting the htmlText property we were resetting he text property, which was causing the problem.