10 Replies Latest reply on Jan 12, 2010 1:07 PM by TSGal

    Field Script Triggers disappear after assigning a Button to the field

    nsturmwind

      Summary

      Field Script Triggers disappear after assigning a Button to the field

      Description of the issue

      FileMaker Product(s) involved:FileMaker Pro Advanced 10.0v3Operating System(s) involved:Mac 10.5.8Detailed description of the issue:After assigning a button script to a field that has existing assigned script triggers, no script triggers appear in the Set Script Triggers dialog. The red asterisk still appears in the bottom-left corner of the field, and the existing triggers still trigger. (This part of the bug is more-or-less cosmetic.) Futhermore, if new script triggers are assigned (even to events that were not previously assigned) after assigning the button script, the existing triggers no longer trigger. (This part of the bug causes changes to previously assigned settings.) Exact steps to reproduce the issue: [See revised steps in a later message in the thread that more clearly demonstrate the second part of the bug.] 1.  Create a new database.2.  Create a single text field called "Text" and place it on a layout. 3.  Create three scripts called "Trigger Enter", "Trigger Modify", "Button", each containing a Show Custom Dialog step that prints the name of the script (or similar identifying information). 4.  Enter layout mode.  5.  Right-click on the field, select Set Script Triggers... Assign the "Trigger Enter" script to the OnObjectEnter event for Browse mode. Click OK. 6.  Enter browse mode. Verify that the Trigger Enter script displays the dialog when the field is entered. Enter layout mode again. 7.  Right-click on the field, select Button Setup... Select Perform Script and assign the script "Button". Click OK. 8.  Right-click on the field, select Set Script Triggers... Click OK. In step 8 the OnObjectEnter event appears to not be assigned. However, it is still assigned, and this can be verified by the following steps: 9.  Right-click on the field, select Button Setup... Select Do Nothing. Click OK. 10.  Right-click on the field, select Set Script Triggers... Click OK. In step 10 the OnObjectEnter script trigger is visible again.  For the second part of the bug, repeat step 7 to re-assign the button, and then take the following steps: 11.  Right-click on the field, select Set Script Triggers... Assign the "Trigger Modify" script to the OnObjectModify event for Browse mode. Click OK. 12.  Right-click on the field, select Button Setup... Select Do Nothing. Click OK. 13.  Right-click on the field, select Set Script Triggers... Click OK. In step 13 only the OnObjectModify event has an assigned script. 14.  Enter browse mode. Click in the field. Type in the field. In step 14, the "Trigger Enter" script no longer triggers when the field is entered, but the "Trigger Modify" trigger does trigger when data is entered into the field. Expected Result:In step 8, the OnObjectEnter event should show that the "Trigger Enter" script is assigned. In step 13, the OnObjectEnter should show that the "Trigger Enter" script is assigned and the OnObjectModify event should show that the "Trigger Modify" script is assigned. In step 14, the "Trigger Enter" dialog should appear when entering the field, and the "Trigger Modify" dialog should appear when typing in the field. Actual Result:In step 8, the OnObjectEnter event shows no assigned script. In step 13, the only the OnObjectModify event shows that the "Trigger Modify" script is assigned. The OnObjectEnter event shows no assigned script. In step 14, the "Trigger Enter" dialog does not appear when entering the field, although the "Trigger Modify" dialog appears when typing in the field.  Exact text of any error message(s) that appeared:NoneAny workarounds that you have found: Re-assign all field script triggers after assigning a button script to a field.  

        • 1. Re: Field Script Triggers disappear after assigning a Button to the field
          comment_1
            

          The reason why this happens is this: when you set a field (or any other object) as a button, you are creating a new object - a group, actually, of which the original object is a member. The script triggers attached to the field remain functional, but you cannot edit them until you ungroup the compound object and select the field itself.

           

           

          BTW, it's hard to see the point of attaching script triggers to a field that is also a button: it cannot be entered/modified/exited etc.

          • 2. Re: Field Script Triggers disappear after assigning a Button to the field
            nsturmwind
              

            That makes sense; it's just a little counter-intuitive. Particularly the part where assigning a new script trigger to the group removes any existing script triggers that were attached to the field.

             

            As for why do this, I sometimes find it useful to have a field that is enterable only when certain conditions are met. I can accomplish this by assigning a button to the field with a script that checks the condition and then performs Go To Field. Once the field has been entered (by means of the script), the other script triggers (modification, exit, etc.) remain useful.

             

            I picked a confusing example when I gave OnObjectEnter along with assigning a button.

            • 3. Re: Field Script Triggers disappear after assigning a Button to the field
              comment_1
                

              nsturmwind wrote:

              As for why do this, I sometimes find it useful to have a field that is enterable only when certain conditions are met. I can accomplish this by assigning a button to the field with a script that checks the condition and then performs Go To Field.


              That was before version 10 - now you can do this with a script that runs OnObjectEnter, and if the conditions are NOT met, it exits the field.

               

               

               


              nsturmwind wrote:

              assigning a new script trigger to the group removes any existing script triggers that were attached to the field.


              I haven't observed this.

               



              • 4. Re: Field Script Triggers disappear after assigning a Button to the field
                nsturmwind
                  

                What you have suggested does not provide the same behaviour as assigning a button. OnObjectEnter triggers after the field has been entered, so the script can't prevent the field from being entered. If the script simulates an un-enterable field as you suggest, by having the script exit the field, OnObjectExit will be triggered which is not desired.

                 

                The specific situation in which I was trying to use this was encrypting/decrypting data in a field on the fly. When the user clicks on the field, a button script attempts to decrypt the data. If there is an error decrypting, the user is not allowed to enter the field. If there is no error, the script uses the Go To Field step to enter the field. When the user exits the field, OnObjectExit triggers and encrypts the data. If I use an OnObjectEnter trigger as you suggest, and the OnObjectEnter script exits the field because data decryption failed, then the OnObjectExit will trigger and re-encrypt the already encrypted data. This could be worked around by use of global variables, but it seems kludgy.

                 

                In any case, there is still a definite bug regarding the new script trigger removing existing script triggers. Try this variation of my original steps, which demonstrates the problem more clearly.

                 

                1.  Create a new database.

                2.  Create a single text field called "TextField" and place it on a layout.

                 

                3.  Create two scripts called "Trigger Keystroke" and "Trigger Modify", each containing a Show Custom Dialog step that prints the name of the script (or similar identifying information).

                 

                4.  Create a third script called "Button" that contains a Show Custom Dialog step that prints the name of the script, and then performs a Go To Field [TextField].

                 

                5.  Enter layout mode. 

                 

                6.  Right-click on the field, select Set Script Triggers... Assign the "Trigger Keystroke" script to the OnObjectKeystroke event for Browse mode. Click OK.

                 

                7.  Right-click on the field, select Button Setup... Select Perform Script and assign the script "Button". Click OK.

                 

                If you enter browse mode and test it at this point, when you click on the field you see the "Button" dialog and the field is entered. When you type, you see the "Trigger Keystroke" dialog. This is correct so far.

                 

                8.  Right-click on the field, select Set Script Triggers... (Note that the OnObjectKeystroke is now no longer showing as assigned, because you are operating on the group.) Assign the "Trigger Modify" script to the OnObjectModify event for Browse mode. Click OK.

                 

                Test it again at this point. When you click on the field you see the "Button" dialog and the field is entered. When you type, you see the "Trigger Modify" dialog, but NOT the "Trigger Keystroke" dialog.

                 

                You can also use the following steps to verify that the OnObjectKeystroke event has really been unassigned:

                 

                9. Right-click on the field, select Button Setup... Select Do Nothing. Click OK.

                 

                10. Right-click on the field, select Set Script Triggers...

                 

                At this point you can see that only the OnObjectModify event is assigned.

                • 5. Re: Field Script Triggers disappear after assigning a Button to the field
                  comment_1
                     You must do #8 before #7. The way you have it now, the OnObjectModify trigger is attached to the button (i.e. the group), not to the field - and of course, the button is never modified by the user.
                  • 6. Re: Field Script Triggers disappear after assigning a Button to the field
                    nsturmwind
                      

                    Hi comment,

                     

                    Please read again carefully. The OnObjectModify trigger (the one assigned to the button) DOES work. The OnObjectKeystroke trigger (the one assigned to the field before the button was assigned) STOPS working after the OnObjectModify trigger is assigned.

                    • 7. Re: Field Script Triggers disappear after assigning a Button to the field
                      comment_1
                         Yes, you are right - if you do it in that order, it seems the triggers interfere with each other. But it makes no sense to do it in that order - if you do it the way I suggested, all 4 scripts will run as expected.
                      • 8. Re: Field Script Triggers disappear after assigning a Button to the field
                        nsturmwind
                           You are correct regarding your workaround, but my point is that FileMaker is exhibiting inconsistent (and I would say buggy) behaviour. Assigning a script trigger, then assigning a button, then assigning a second script trigger should not erase the first script trigger.
                        • 9. Re: Field Script Triggers disappear after assigning a Button to the field
                          philmodjunk
                            

                          I can confirm this with Windows XP on Filemaker Pro 10v3 Advanced:

                           

                          I created two scripts that simply use show custom dialog to display different text messages.

                          I selected a field and set the "onObjectEnter" trigger to run script 1.

                          I then set up the field as a button that performed go to Field--specifying this same field. Thus, clicking the field should place the cursor in the field and trigger script 1.

                          I then assigned a new script trigger OnObjectExit for this button group to perform script 2.

                           

                          When I test this, I find that clicking the field places the cursor in the field, but no script is triggered until I exit the field when script 2 is performed. If I ungroup the button and check for my original script trigger setting for script 1, I find that no script trigger is selected for the field.

                           

                          Note that if you assign a script trigger for one field and then group the fields, the script trigger setting remains selected for the first field. The trigger remains functional and it can be either cleared or assigned to both fields--which is not exactly what we get with the button setup.

                           

                          This looks like either a bug or undocumented script trigger behavior.

                          • 10. Re: Field Script Triggers disappear after assigning a Button to the field
                            TSGal

                            All:

                             

                            Thank you for your posts and discussion.

                             

                            From the testing I have done, it appears that script triggers are removed after a button is assigned.  Attaching the script triggers to the button, and then removing the button will keep the script triggers.

                             

                            I have forwarded this entire thread to our Development and Software Quality Assurance (Testing) departments for review and awaiting an explanation.

                             

                            TSGal

                            FileMaker, Inc.