9 Replies Latest reply on Dec 1, 2012 2:33 AM by V.K.R (Vijay)

    <s:textarea> auto scrolling fail


      I'm using Flash Builder 4 with Flex 4 to build a chat and I'm unable to make an auto scrolling for <s:textarea> Spark component!


      I've tried "textarea.scroller.verticalScrollBar.value = textarea.scroller.verticalScrollBar.maximum" and "textarea.appendText()" but it doesnt scrolls the vertical bar totally! It remains a little bit cause of "\n" in the final of each message.


      In Flex 3 I used to do "textarea.verticalScrollbar = textarea.maxverticalScrollbar" and it worked always!


      Anyone can helpme?

        • 1. Re: <s:textarea> auto scrolling fail
          VRPDeveloper Level 3

          Adobe help says that


          If the new text exceeds the capacity of a TextArea control and the horizontalScrollPolicy property is set to true (the default value), the control adds a scrollbar.


          if you want vertical scrollbar then use verticalScrollPolicy....

          • 2. Re: <s:textarea> auto scrolling fail



            In  <s:textarea> auto scrolling fail.... then just add property <......verticalScrollPolicy="auto"......>  n if it is not working then use <...........verticalScrollPolicy="true".............> nothing else u have to add in that textarea . and u can add verticalScrollPosition...


            wish it will helpful for u...

            • 3. Re: <s:textarea> auto scrolling fail
              XXXxxx2 Level 1

              The problem is not if the scroll bar appears or not. It appears, but it doesnt make auto scrolling completely to the bottom as Flex 3!


              I tried to set verticalScrollPolicy="on" and a lot of stuffs, but didnt work.


              See printscreen below:


              Sem título.jpg

              • 4. Re: <s:textarea> auto scrolling fail
                rashmin.d Level 1

                k........ see u should remove all the other prop. related to scroll and just add verticalScrollPolicy and verticalScrollPosition nothing else .. it should work ......i tried your example and its working ........ then also try this way..... or send me that whole textarea tag.... but i think this will solve your problem....


                and if u are giving "\n" in input text then remove that one also.. just add these two property to textarea and in textinput use textinput event and show that input in textarea... it should work... let's see..... i hope it will work...

                • 5. Re: <s:textarea> auto scrolling fail
                  -BoNzO- Level 2

                  XXXxxx2 is right.


                  I believe his approach would work on any IViewPort based component other than RichEditableText but RET is just borderline insane.


                  The amount of understanding an application developer has to have to make this work is just too high; It's even worse than that since to make this work there is a litle hack involved that depends a lot on RET's implementation, that is, if you want to set the value to the maximum all during one invalidation so that you see no jumps ( which would be crap )


                  The biggest issue is how convoluted RET can be and that there isn't enough easier hooks available to developers:


                  Because range->set value and range->set maximum don't dispatch events ( even undocumented, magic string typed ones would be fine ) I have to listen to viewPort's contentHeight change events. But then it goes like this:


                  _ viewport contentHeight changed

                  _ Therefore the scrollbar maximum is changed by the framework

                  _ I set scrollbar value to its maximum

                  _ in scrollbar commitProperties, my value is retained, great !

                  _ in that same commitProperties, the verticalPosition on viewPort is updated as expected

                  _ A bit later, in RET commitProperties a viewPort's contentHeight is dispatched again because TextContainerManager does some crazy stuffs

                  _ Therefore the framework changes the scrollbar maximum again...

                  _ So I try to set the value to equal the maximum again...

                  _ Then big fail, the next line in RET commitproperties (just after the above event dispatching ) just override the value I just set with the old one.



                  So please, dispatch more events in setters, even undocumented ones, even if they don't trigger any bindings. You can even check if there are any listeners before dispatching as you did in other places.


                  That or simplify RET, I don't know why TLF might decide to update the contentHeight if I just changed the vertical position. I'm really expecting just one contentHeight PropertyChange event when the content of the RET changed.

                  • 6. Re: <s:textarea> auto scrolling fail
                    KnuX75002 Level 1



                    Did you find a solution ?


                    I'm interested because I have the same problem...

                    • 7. Re: <s:textarea> auto scrolling fail
                      XXXxxx2 Level 1

                      Yes, I simply updated the SDK to the newest version and used this code:


                      textMessages.scroller.verticalScrollBar.value = textMessages.scroller.verticalScrollBar.maximum;

                      • 8. Re: <s:textarea> auto scrolling fail

                        add these line after the text property of textarea is updated



                        textarea.scrollToRange(int.MAX_VALUE - 1,int.MAX_VALUE);

                        textarea..scroller.verticalScrollBar.value = textarea.scroller.verticalScrollBar.maximum ;


                        • 9. Re: <s:textarea> auto scrolling fail
                          V.K.R (Vijay) Level 1

                          Use "appendtext" property in the textarea flex 4.5


                          when u enter the text and press enter key in the enter key function you have to use appendText




                          messageArea is the id of the text area

                          msg is the variable which contains the value from the text box