6 Replies Latest reply on Jun 11, 2010 7:12 AM by sleblang

    [FB4] TextInput: Limiting number of characters

    sleblang Level 1

      I have a spark textinput which I added a custom button as part of the skin. The button is located on the far right side of the input. The issue I am having is that when text is entered I need to have it stop just before the button and then append to the text string as more characters are added. Currently what is happening is that the text is going behind the button until it reaches the end of the text input. I tried changing the widthInChars property, however that doesn't seem to have an affect.

       

      I have attached an image illustrating the issue with the vertical red line showing where I want the text to end.

       

      Thanks.

       

      search.gif

        • 1. Re: [FB4] TextInput: Limiting number of characters
          David_F57 Level 5

          hi,

           

          In your skin you need to look at textdisplay object and set its right="xx" where xx is the button width plus say 2-3 pixels

           

              <s:RichEditableText id="textDisplay"

                        verticalAlign="middle"

                        widthInChars="10"

                        left="1" right="{buttonWidth+4}" top="1" bottom="1" />

           

          David

          1 person found this helpful
          • 2. Re: [FB4] TextInput: Limiting number of characters
            sleblang Level 1

            Thanks for the assistance. I tried your suggestion and it's still not functioning as I need. However, if I look in design view of the textinput's skin, I do see that the RichEditableText length has been restricted to just before the button starts - which is what I desire. However, when the application runs, text continues to go behind the button. Here is the code in the skin:


            // TextInput Skin    
            
            
            <s:RichEditableText id="textDisplay" widthInChars="10"
                          verticalAlign="middle"
                             left="1" top="1" bottom="1" right="35" />
                 
                 <s:Button enabled="{textDisplay.text.length>0}" click="search_btn_clickHandler(event)"
                             width="30" height="18" right="2" top="2"
                             skinClass="com.usa.skins.SearchButtonSkin"
                             id="search_btn"
                             toolTip="Search"  
                             y.disabled="1" x.disabled="788" right.disabled="0" />
            

             

            Thanks.

            • 3. Re: [FB4] TextInput: Limiting number of characters
              David_F57 Level 5

              hi,

               

              i'm not an expert at this "yet " but maybe reduce the widthinchars or even remove it may do the trick, the Adobe guys would understand this better but at a guess this overrides the set width.

               

               

              David.

              • 4. Re: [FB4] TextInput: Limiting number of characters
                sleblang Level 1

                Uggh....so frustrating! So I removed widthInChars and that definitely didn't work as the text just continued on past the button and didn't shift/scroll. According to the docs regarding widthInChars:


                "This property will be ignored if you specify an explicit width, a percent width, or both left and right constraints."


                Well, it looks like I might have finally stumped you You have helped me before and I certainly appreciate it. If you would like another shot at a problem, here's a link to another issue I am having - http://forums.adobe.com/thread/656836?tstart=0


                Thanks again for your assistance!!!

                • 5. Re: [FB4] TextInput: Limiting number of characters
                  David_F57 Level 5

                  hi,

                   

                  Not stumped  , just don't know ....

                   

                  actually haven't had a chance to look at it but if you look at other parts of the skin you will see that everything gets set they don't care what you want..

                   

                   

                          override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

                          {

                              if (getStyle("borderVisible") == true)

                              {

                                  border.visible = true;

                                  shadow.visible = true;

                                  background.left = background.top = background.right = background.bottom = 1;

                                  textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 1;

                              }

                              else

                              {

                                  border.visible = false;

                                  shadow.visible = false;

                                  background.left = background.top = background.right = background.bottom = 0;

                                  textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 0;

                              }

                   

                              borderStroke.color = getStyle("borderColor");

                              borderStroke.alpha = getStyle("borderAlpha");

                   

                              super.updateDisplayList(unscaledWidth, unscaledHeight);

                          }

                  textDisplays right property is always going to revert to 1  or zero...
                  so

                                  textDisplay.left = textDisplay.top = textDisplay.right = textDisplay.bottom = 1;

                  becomes

                                  textDisplay.left = textDisplay.top = textDisplay.bottom = 1;

                                 textDisplay.right=35

                   

                  David.

                  • 6. Re: [FB4] TextInput: Limiting number of characters
                    sleblang Level 1

                    That fixed it. Thank you very much!!!!