4 Replies Latest reply on Oct 20, 2010 2:06 PM by AbhiFusion

    Carriage return in TextArea Flash component in Director 11

    maska2006

      Hello.

       

      I have a very big problem now

      Neither embedded Flash movies with textareas or standard flashcomponent TextArea from Director tool pallete do not react on keyboard button "Enter" pressings. There is no carriage return after ENTER button is pressed. The same with End and Home buttons!!

       

      Please help with any advise.

      Is that a common bug?

       

      See attached test.dir file. Try to type something in both textareas and then press ENTER button on keyboard. You should realize then what I'm crying about(((

       

      Alexey

        • 1. Re: Carriage return in TextArea Flash component in Director 11
          Chunick Level 3

          I don't use flash components at all so until now I hadn't noticed this obvious bug. I can confirm that the Enter key is being passed to Director's 'on keyDown' handler (with eventPassMode set to #passAlways, of course), but it never makes it to the flash component:

           

          -- after typing in the textarea component and hitting the Enter key, do this in the message window:

          put sprite(1).text

          -- "asdf asdf asdf"

           

          the last character should be a RETURN character, thus it should look like this:

          -- "asdf asdf asdf

          "

           

          Furthermore, when trying like this:

           

          sprite(1).text = numToChar(10) & numToChar(13)

          or this:

          sprite(1).text = RETURN

           

          it does set sprite(1).text = RETURN, which can be seen in the message window:

          put sprite(1).text

          -- "

          "


          but visually, it doesn' get displayed.

          • 2. Re: Carriage return in TextArea Flash component in Director 11
            maska2006 Level 1

            FYI

             

            In Director MX 2004 this bug with carriage return is absent.

            • 3. Re: Carriage return in TextArea Flash component in Director 11
              contempt.productions

              I too struggled with this issue. If you're looking for a solution still I have written one. Used the attached script in your Flash document, I spent a few days going back and forth between Director and Flash to figure this one out. Basically what I do is attach a key listener to the movieclip containing the textfield object that on keyDown gets the currently focused textField (this way it will work with multiple textField objects). After that it determines if the enter key is hit and if it is inserts a "/n" break at the selection starting point. The only issue is if you select a whole word in the textField and hit enter a break will be placed at the beginning of the highlighted word and that word will not be deleted. Hopefully this helps.

               

               

              -b

               

               

               

               

              // BY / contempt.productions inc.  10.30.09

              // Director 11.5 fix for bug where dynamic textfields don't register ENTER or RETURN key in Flash sprites

              // Solution involves inserting a \n carriage return wherever cursor insertion point starts.

              // In Flash this adds 2 carriage returns for every hit of the enter/return key

              // In Director 11.5 it adds 1 carriage return

              // Change "body_txt" to represent the dynamic textField object this script is referencing

               

              myListener = new Object();

              myListener.onKeyDown = function() {

              _global.textFocus = Selection.getFocus();

              // get a string of the path to the currently focused textField object

               

              _global.selStart = Selection.getBeginIndex();

              // get the insertion point, this is the start of any selection

               

               

              var multiText = body_txt.text;

              // get the text from the current textField object

               

              var theKey = Key.getCode();

              // get the current keyCode (13 is the keyCode for "enter/return" key)

               

              if (eval(textFocus) == eval(body_txt)) {

              // determine if focused textField and current textField are the same

               

               

              if (theKey == 13) {

              // enter key is pressed

               

              var firstPart = multiText.slice(0, selStart);

              // get the current textField's text from the beginning to the insertion point

               

              var secondPart = multiText.slice(selStart, multiText.length);

              // get the textField's text from the insertion point to the string's end

               

               

              body_txt.text = firstPart+"\n"+secondPart;

              // concatenate the first and second part of the textField's text with a carriage return

               

              Selection.setSelection(selStart+1,selStart+1);

              // place the text insertion point properly

               

              }

              }

              };

              myListener.onKeyUp = function() {

              var theKey = Key.getCode();

              };

              Key.addListener(myListener);

              • 4. Re: Carriage return in TextArea Flash component in Director 11
                AbhiFusion Level 1

                Flash saves carriage returh as Chr(13)

                 

                Use the following to get the carriage return where you output textarea data:

                 

                replace(form.textAreaVariable, chr(13), "<br>", "all");