9 Replies Latest reply on Apr 27, 2008 9:49 PM by _peabulls_

    TextArea content

    GerryIsHere Level 1
      Hi there!

      How do I make the content of a TextArea NOT selectable ?
      Many thanks in advance for your advices.

      Best regards,

        • 1. Re: TextArea content
          before i accidently answer the wrong question .. do you mean:

          A 'TextArea' .. the ActionScript component which wraps the native ActionScript TextField object

          B 'TextField' .. the ActionScript native object -- dynamic or input text placed during authoring or attached at runtime via MovieClip.createTextField()
          • 2. Re: TextArea content
            GerryIsHere Level 1
            Thanks for responding!
            I mean the TextArea Component (part of the User Interface Components Library in Flash 8 Pro).
            • 3. Re: TextArea content
              _peabulls_ Level 1
              sorry this took so long ..

              and also .. i may have some bad news for you .. the flash components (especially from as2.0 days) are notorious for not offering the features that one might want.

              before i go on .. i should point out i rarely used said components for the reason that i needed components with differing features as the ones offered .. therefore i am by no means an expert (so you should get a second opinion on all of what is to follow)

              TextArea has no option to make it's text unselectable in its API .. a couple things you can do are:

              myTextArea.editable = false;

              this still allows the text to be selected but not changed

              fishy.enabled = false;

              this keeps the text from selecting .. but grays everything out

              fishy.focusTextField.selectable = false;

              ok .. there a lot of things wrong with this one
              [1] it is completely undocumented so we don't know what it's really doing
              and when it will break the other features of TextArea
              [2] it makes the nifty border around your text field go away

              //--- --- - - -

              so .. sorry i don't have anything more helpful .. hopefully someone who is more familiar with this component can say something useful
              • 4. Re: TextArea content
                _peabulls_ Level 1
                an idea .. i'm not sure how well this will work .. you could try having a listener listening for when the selection changes on your TextArea .. and when it does .. manually set the selection to nothing .. but this seems like it could be a horrible hack .. up to you
                • 5. TextArea content
                  GerryIsHere Level 1

                  Originally posted by: _peabulls_
                  myTextArea.editable = false;

                  Thanks for the time you dedicated to this problem !!!
                  In addition to your quoted suggestion, I added:

                  TextAreaInstanceName.editable = false;
                  TextAreaInstanceName.onPress = null;
                  TextAreaInstanceName.useHandCursor = false;

                  This combination perfectly works...

                  Thanks again!

                  • 6. Re: TextArea content
                    kglad Adobe Community Professional & MVP
                    lol. that's a bit of overkill. (and i sure hope you don't need to use scrolling.)
                    • 7. TextArea content
                      GerryIsHere Level 1
                      Hello kglad !

                      Is that you who suggested the onPress and useHandCursor ?
                      I found the solution in an old .fla where I put as a comment that solution was found long ago in this forum.

                      If the answer is "yes" just tell me and I'll give you the credit for this bulletproof solution. :-)

                      Best regards,

                      • 8. Re: TextArea content
                        kglad Adobe Community Professional & MVP
                        i don't remember posting that. i saw your message right after you posted it and couldn't see any good solution for a textarea (ta).

                        the trouble with assigning a mouse handler to the ta, is you can't use the ta scrollbars. so, if you have text that doesn't fit the display area, you have a problem and would be better off using a textfield and the uiscrollbar or make your own scrollbar.

                        if you don't have text that exceeds the ta display region you'd still be better off using a textfield while disabling its selectable property.
                        • 9. Re: TextArea content
                          _peabulls_ Level 1
                          i tend to agree with kglad here .. while disabling the default selection action by injecting a null mouse handler into the parent MovieClip of your TextArea may be clever .. it is almost impossible to know the ramifications this might have on any of the functionality native to TextArea .. this is a problem every time we try to 'fix' a piece of code by doing something not explicitly allowed by it's API .. as i pointed out above with the hack:

                          fishy.focusTextField.selectable = false;

                          on a side note if you are willing to write a crazy work around you could consider placing MovieClip with an invisible hitArea the same size as the textArea above the TextArea .. assign a null onMouseDown and this will intercept your mouseDown events (keeping you from being able to select the text) without breaking text area .. then you could have your blocking clip adjust sizes to allow you to still click through to the scroll bar..

                          or you could just use a TextField like kglad suggests

                          <sorry if i'm a little punchy .. i think it's past my bedtime>