2 Replies Latest reply on Jul 30, 2015 1:33 AM by jgalt

    How can I make this calculation field update using an OnObjectKeystroke script trigger?

    jgalt

      The problem that I am running into is the calculation field is always one keystroke behind what the user is typing. How can I keep these two fields in perfect sync as the user is typing?

       

      I can easily do this with the OnObjectModify script step but I want to do this with the OnObjectKeystroke command so I can capture if the user types (enter, tab or return).

       

      bVNanR

       

      Here is a sample file:

        • 1. Re: How can I make this calculation field update using an OnObjectKeystroke script trigger?
          ErikWegweiser

          Greetings. The concept of the 'trick' is that you want to perform your (search) triggered script AFTER the letter that's typed appears, but the nature of the script trigger is that it performs the action and then (depending on the result of the triggered script) completes the triggered event; that is, the typed letter appearing.

           

          The first essential key to getting around this is capturing the keystroke after it is typed (as soon as it triggers the script). Use the Get(TriggerKeystroke) function as probably the first step of your triggered script. Then you can update the contents of your field with the typed key, so it displays. Then perform your action (search) based on the updated content of the field. Lastly—and this is important—exit the script with a boolean 0 (false) value. That will prevent the keystroke from actually being typed (which you want, because your script has already done so).

           

          That's only a simple, quick explanation, since there's a lot more you need to do in the script to handle things like text being typed other than at the end of the field's contents and what to do when the delete key is pressed (Hint: Code() function ), etc.

           

          HTH

          • 2. Re: How can I make this calculation field update using an OnObjectKeystroke script trigger?
            jgalt

            Yes, the key to solving the problem was adding a script step that set the users captured keystroke to the field.

            Set Field [TABLE::search ; Get ( ActiveFieldContents ) & Get ( TriggerKeystroke ) ]

            Exit Script [Result : False]

             

            Sorry, I should have mentioned that for the sake of keeping the conversation simple I had stripped out a bunch of the other script steps from my example file.

             

            Thanks for your reply.