1 Reply Latest reply on Dec 25, 2014 1:22 PM by philmodjunk

    Trigger a script by selecting text



      Trigger a script by selecting text


      The requirement is to help the user enter text into a text field by changing the text that was selected or suggesting alternative text. To do this a script needs to be triggered when the user selects a word or more than one word.

      I can do this in two steps using the OnObjectKeystroke script trigger: (1) the user selects the text then (2) types a key (e.g. tab) at which point the script is triggered and figures out the selected text using a combination of Get ( ActiveFieldContents ), Get ( ActiveSelectionStart ), and Get ( ActiveSelectionSize ).

      How can I trigger the script without the second step? Ideally, the user would double click the word, or click and drag across multiple words, and the script would be triggered without further action.



        • 1. Re: Trigger a script by selecting text

          i've managed to almost do this just with OnObjectEnter. The user clicks a word in the text field and the script scans left and right from Get (activeselectionstart) to either the beginning and end of the word or the beginning or end of the block of text with a specific style. That's not quite what you want here, but it's close, maybe you can combine this with Get ( ModifierKeys ) to allow selecting multiple words by shift clicking each word in turn...

          I used this method in my Adventures in FileMaking series to create a kind of "bibliography" where clicking the underlined text open's a URL to that resource's web site.