1 Reply Latest reply on Jan 7, 2010 1:46 PM by Woodifer01

    Make a substring unselectable

    Woodifer01

      I am working on a twitter app and I am giving users the option to add or remove the hashmark #uvu.  This is toggled on or off with a simple checkbox.  When it is toggled on, #uvu appears in the textarea.  Is there a way to make #uvu unselectable but the rest of the text selectable?  I want #uvu to stay at the end of the string.  I've seen this done on the Adobe Max Companion Air app (for those who went to Adobe Max... I am trying to replicate that build).

        • 1. Re: Make a substring unselectable
          Woodifer01 Level 1

          I rethought this process.  Instead of making the substring unselectable, I place two textArea components on top of each other.  The background of the top one was transparent.  The bottom textarea's selectable property was set to false and had my static text in it.  The top textarea was set to selectable.  When you type in the top text area, the bottom text area copys the text and appends the static unselectable text I wanted.  Here is the code:

           

          <mx:Canvas id="tweetCanvas" width="100%" height="146" backgroundColor="#353535" bottom="0">
                                  <mx:TextArea id="hashtag" text="{tweet.text}#UVU" height="80" y="15" width="295" x="15" creationComplete="offFocus(event)"

                                        borderStyle="none" cornerRadius="0"  color="#767676" selectable="false" editable="false"/>

                                  <mx:TextArea id="tweet" text="[tweet]" height="80" y="15" width="295" x="15" borderStyle="none" cornerRadius="0"                               backgroundAlpha="0.0"  focusIn="onFocus(event)" focusOut="offFocus(event)"/>                                       
                                  <mx:Button x="250" y="103" label="TWEET" width="60" height="20" fontWeight="normal" fontSize="8" click="postTweet.send()"/>
                                  <mx:Text x="15" y="103" id="textCount" text="{140 - hashtag.text.length}" updateComplete="updateStatus(event)" color="#FFFFFF"                               fontWeight="bold" fontFamily="Arial" fontSize="12"/>
                                  <mx:CheckBox x="113" y="101" label="INCLUDE HASHTAG" color="#FFFFFF" selected="true" id="checkHash" click="hashTags()"
                                      textRollOverColor="#FFFFFF" textSelectedColor="#FFFFFF" fontFamily="Arial" fontWeight="bold"/>

          </mx:Canvas>

           

          Hope this helps someone in the future