5 Replies Latest reply on Nov 15, 2011 12:38 PM by philmodjunk

    Any hidden gotchas with 'onObjectKeystroke'?

      Title

      Any hidden gotchas with 'onObjectKeystroke'?

      Post

      I wanted to add some functionality to the FileMaker native UI to mimic web forms a bit more closely.  Essentially, add in the ability to launch a search script via hitting 'Enter' from the text entry field.  So here is what I found and did:

      First, set up the fields in question with a script trigger "onObjectKeystroke" to run this script:

      If [ Code(Get(TriggerKeystroke)) = 10 or Code(Get(TriggerKeystroke)) = 13 ]

      If [ Get ( ActiveFieldName ) = "Slctr_Course" ]
         Perform Script [ “CM Simple Course Search” ]
      Else If [ Get ( ActiveFieldName ) = "Slctr_Author" ]
         Perform Script [ “CM Simple Author Search” ]
      Else If [ Get ( ActiveFieldName ) = "Slctr_PotlAuthor_Name" ]
         Perform Script [ “CM Simple Potl_Author Search” ]
      Else If [ Get ( ActiveFieldName ) = "Slctr_Topic" ]
         Perform Script [ “CM Simple Topic Request search” ]
      Else If [ Get ( ActiveFieldName ) = "Slctr_FdbkV2_Course1" ]
         Perform Script [ “CM Simple Feedback Search” ]
      End If

      End If

       

      This is a small helper script that does the keystroke checking and then launches the appropriate subscript.  I have 5 possible search fields that are using this script.  I had already broken out the search scripts for the individual fields into separate scripts so that I didn't end up with a bunch of huge If/Else clauses in a single script.  I realize that ActiveFieldName might be a bit loosey-goosey, but should be fine for 99% (90%?  :) ) of the cases.  It seems that it might only be a problem if you have two fields on separate tables that have the same name; then you could include the table name in the check.  Not an issue with my current implementation.

       

      My question is:  are there any hidden gotchas to using this method?  Performance hits, extraneous launching of the script, inability to enter text in the field, etc.

       

      Thanks,

      Justin