1 Reply Latest reply on Jan 27, 2014 3:46 AM by philmcgeehan

    Format currently selected text script

    philmcgeehan

      Title

      Format currently selected text script

      Post

           I'd like to be able to select some of the text in a field, and then click a button to change the text colour to Red.

           Something like the answer to this post would be great
      selected text

           However, when I click on the button, the selection size goes to zero and the position goes to the end of the selection.

           For instance, if I had text of 100 characters and selected from position 25 with a size of 20; when I click the button it will set the position to 45 and the size to zero, and nothing gets formatted!

           How do I keep the selection active while pressing a button?

        • 1. Re: Format currently selected text script
          philmcgeehan

               Never mind, I just needed to set the start and size as variables first.

               I now use:

               TextColor (
                   Middle (  Get ( ActiveFieldContents ) ; $start ; $size ) ;
                       If ( Get ( ScriptParameter ) = "red" ;
                           RGB ( 255 ; 0 ; 0 ) 
                       )
               )