10 Replies Latest reply on Jul 28, 2015 8:14 AM by RickWells-Cole

    Dynamic resize of text into field

    mcrostie

      Hi

       

      Is a text field able to know if the text entered is "overset" (does not fit within the field boundries) and therefore able to be dynamically adjusted to fit?

       

      or

       

      Has can anyone lead me to where there been any discussion about this?

       

      Thanks

       

      Michael

        • 1. Re: Dynamic resize of text into field
          shearn

          Not aware of any way to detect, in general, if text extends beyond the border of a text field. Two things that may work, depending on your situation.

           

          One is to use sliding fields: typically used for printed reports because sliding only takes place in preview mode or when printed, sliding has the ability to shrink the size of a field until it "hits" content. It means you need to oversize the dimensions of the field but it's very effective.

           

          Another is a trick to determine the number of rows of text. It requires a script that goes to a layout whose page size is set to one line of text high. Place the field in question on the layout,  the same width as on the layout you're measuring for and turn on sliding up (and reduce size of enclosing part). By going into preview mode you'll get a whole lot of pages, one line high. The number of pages represents the number of rows that field has at a given width regardless of word-wrapping.

           

          I hope one of these suggestions is useful to you.

          • 2. Re: Dynamic resize of text into field
            Mike_Mitchell

            Other options include:

             

            - Using Conditional Formatting to reduce the text size based on the length of the field (use the Length function). This can be a pain, due to the need to engage in trial and error to determine the breakpoints, but can be effective.

             

            - Using the Virtual List method to split the text into multiple fields (similar to Steve's method) and moving to a List view. Do a search for "Virtual List" on this forum to find references to this excellent method.

             

            HTH

             

            Mike

            • 3. Re: Dynamic resize of text into field
              raybaudi

              mcrostie ha scritto:

               

              Is a text field able to know if the text entered is "overset" (does not fit within the field boundries) and therefore able to be dynamically adjusted to fit?

              Yes, it is able.

              I attach an example for the v11.

              Note that to make it work on the 12, you will need to edit the scripts.

              • 4. Re: Dynamic resize of text into field
                mcrostie

                Thanks Steve and Mike,

                 

                I have a little more research to follow now.

                 

                I have found a method for the length function, but i also have the number of lines variable as well

                 

                MM

                • 5. Re: Dynamic resize of text into field
                  mcrostie

                  Daniele,

                   

                  That is amazing,

                  I have just had a quick look at it, why would there be a difference with FM12

                   

                  Great job

                   

                  Michael

                  • 6. Re: Dynamic resize of text into field
                    mcrostie

                    Hi Daniele

                     

                    I have had a muck around with the script and my issue is now with multi lines. I do want to keep my text within 80 px height, and are having problems understanding the first script line

                     

                    Set Variable [ Value:Let([

                    css = GetAsCSS ( Get ( ActiveFieldContents ) ) ;

                    pStart = Position ( css ; "font-size" ; 1 ; 1 )  + 10;

                    pEnd = Position ( css ; "px;" ; pStart ; 1 ) ;

                    size = Middle ( css ; pStart ; pEnd - pStart )

                    ];

                    GetAsNumber ( If ( IsEmpty ( size ) ; 14 ; size ) )

                    )]

                     

                    I do not seem to be able to get any "Height" from field "2" to run the second part of the script

                     

                    Regards

                     

                    Michael

                    • 8. Re: Dynamic resize of text into field
                      raybaudi

                      Do not look at the first script line !

                      ( it only get the actual font size of the field )

                       

                      Instead change the second script line to:

                       

                      If [ $fontSize ≤ 8 or GetAsNumber ( GetLayoutObjectAttribute ( 2 ; "Height" ) ) ≤ 80 ]

                       

                      BTW: I'm attaching another example.

                       

                      Try to write more than the field height: the font size will go from 18pt down to 6pt.

                      Try even to cut some chars or words ( the font size will increase till 18pt max )

                      Try to enter Layout Mode and change the Height of the field.

                      1 of 1 people found this helpful
                      • 9. Re: Dynamic resize of text into field
                        mcrostie

                        Thank Daniele

                         

                        That works great

                         

                        May I say Correct Answer

                         

                        Regards

                         

                        Michael

                         

                         

                        • 10. Re: Dynamic resize of text into field
                          RickWells-Cole

                          Any idea why your AutoResize script does not work if you change the theme from classic? I am trying to use it in v14 and Classic theme is not supported.  It just seems to go to the smallest size in v14 ??