3 Replies Latest reply on Jul 1, 2011 3:15 PM by philmodjunk

    Scripting changes to Text Formats



      Scripting changes to Text Formats


      I'm brand new to this forum, but not new to Filemaker.  Been using it since it first came out.  I'm not an expert, but I do use a lot of scripts.  However I cannot find a solution to this problem

      One of my applications has text fields.  I'd like to be able to select some (but not all) of the text in a particular field and then kick off a script (probably with a CTRL-? key).  I need the script to change the font size, color, and style of the selected text.  I can't find any script tools to do this.  Can this be done?

      Appreciate any help.  Thanks.

        • 1. Re: Scripting changes to Text Formats

          Don't need a script for that if you expose the formatting bar at the top of your screen. Users can then use the formatting tools there to format text as needed.

          If for some reason that's not a good idea, let us know as there are ways to script this to apply text to the currently selected text in a field. You can even add a small row of buttons on your layout to click to apply specific formats to the selection.

          • 2. Re: Scripting changes to Text Formats

            I'm familiar with the formatting bar and that's what I use now. This is all about speed. I'm trying to get away from all the mouse pointing/clicking needed to change four features on the selected text. I'd much prefer to just type a CTRL key.

            • 3. Re: Scripting changes to Text Formats

              You can experiment with OnObjectKeystroke for your field and use a script to set text formats to the selected text, but the trick is comming up with ctrl-key combinations that aren't already in use for something else. CTRL-I, for example brings up an Insert from Index dialog when you'd like to italicize the text.

              Useful Get functions to use in such a script:

              Get ( TriggerKeyStroke ) // returns the key pressed to trip the script trigger
              Get ( TriggerModiferKeys ) // returns the state of any modifier keys that were down when the trigger was tripped
              Get (activeSelectionsize ) // the number of characters currently selected
              Get ( activeSelectionStart ) // The position of the cursor or the first selected character

              Insert calculated result can be used to replace the currently selected text with the formatted version supplied by your script

              and you can find text formatting functions that will apply text style and size changes to this text that you insert.