7 Replies Latest reply on Jan 31, 2009 3:54 PM by antonjazz_1

    Triggering a script when a drag-and-drop occurs

    antonjazz_1

      Title

      Triggering a script when a drag-and-drop occurs

      Post

      I have a bunch of script triggers that I use to normalize fields (remove extra spaces, line breaks, formatting) after user input has occurred. I trigger them from the OnObjectSave event.

       

      That works fine whenever a field is modified. EXCEPT when it is modified via a drag-and-drop operation. (For instance, someone selects a phone number and drags it into the phone number field.) When this happens the script does not trigger, and the modified field remains un-normalized.

       

      Am I missing something? Is there any way around this?

       

      thanks in advance!

      Anton 

        • 1. Re: Triggering a script when a drag-and-drop occurs
          vcirilli
            

          Read the discussion below.

          Basically a field needs to be active for the trigger to fire.  Drag n Drop does not

          make the target field active.  

           

          I grabbed this from a discussion from another FM forum.  The topic involved Drag n Drop and OnObjectModifiy.  Thanks to: Darren Terry 

           

           

          dragging data into an inactive field does not make that target field active. The focus 
          doesn't shift there. So, for instance, if you drag from one field in 
          a record into another field, the source field remains active even 
          though the target field gets modified. This is true whether you're 
          dragging data into another field in the same record, or into a 
          different record (or indeed, into a different window or file entirely).

          For that reason, drag-and-drop in and of itself cannot trigger a 
          script. But the rules are a little different when you're dragging 
          into an active field (that is, when the active field is the 
          destination of the drag-and-drop, as opposed to the source). In that 
          case, FMP can safely trigger the script because the edited record is 
          also the context in which the triggered script will run. I hope that 
          makes sense.






          • 2. Re: Triggering a script when a drag-and-drop occurs
            raybaudi
              

            Hi antonjazz

             

            > Am I missing something? Is there any way around this?

             

            Drag–and–Drop in FileMaker Pro 10 (white paper and demo)

             

            http://excelisys.com/web/downloads/index.php

            • 3. Re: Triggering a script when a drag-and-drop occurs
              comment_1
                

              antonjazz wrote:

              I have a bunch of script triggers that I use to normalize fields (remove extra spaces, line breaks, formatting) after user input has occurred.


              You don't need a script for this at all. You can define the fields to auto-enter a calculated result (replacing existing data).


              • 4. Re: Triggering a script when a drag-and-drop occurs
                antonjazz_1
                  
                comment wrote: 

                antonjazz wrote:

                I have a bunch of script triggers that I use to normalize fields (remove extra spaces, line breaks, formatting) after user input has occurred.


                You don't need a script for this at all. You can define the fields to auto-enter a calculated result (replacing existing data).


                Well, that would be optimal! But the FMP docs don't specify when auto-entry occurs. I had assumed that it is at record creation time - in which case this won't work when a user is entering/modifying data. But does it occur at specific other times too? (Modification by user? Modification by a script? etc.) If so, do you happen to have any reference to point me to?
                thanks!
                Anton 
                • 5. Re: Triggering a script when a drag-and-drop occurs
                  antonjazz_1
                    
                  Makes perfect sense - thank you!!  Unfortunately, it still begs the question of how to achieve the desired result - namely, making sure that a field's value stays in a normalized form even when drag-and-drop is enabled...

                  vcirilli wrote:

                  Read the discussion below.

                  Basically a field needs to be active for the trigger to fire.  Drag n Drop does not

                  make the target field active.  

                   

                  I grabbed this from a discussion from another FM forum.  The topic involved Drag n Drop and OnObjectModifiy.  Thanks to: Darren Terry 

                   

                   

                  dragging data into an inactive field does not make that target field active. The focus 
                  doesn't shift there. So, for instance, if you drag from one field in 
                  a record into another field, the source field remains active even 
                  though the target field gets modified. This is true whether you're 
                  dragging data into another field in the same record, or into a 
                  different record (or indeed, into a different window or file entirely).

                  For that reason, drag-and-drop in and of itself cannot trigger a 
                  script. But the rules are a little different when you're dragging 
                  into an active field (that is, when the active field is the 
                  destination of the drag-and-drop, as opposed to the source). In that 
                  case, FMP can safely trigger the script because the edited record is 
                  also the context in which the triggered script will run. I hope that 
                  makes sense.


                   








                  • 6. Re: Triggering a script when a drag-and-drop occurs
                    comment_1
                      

                    If an auto-entered calculation is set to replace existing data, it will evaluate any time a local field referenced in the calculation is modified.

                     

                    In your example, the only field that needs to be referenced is Self, so the calculation will trigger every time the field itself is modified, no matter how it's modified (with the exception of importing data with auto-enter disabled).

                    • 7. Re: Triggering a script when a drag-and-drop occurs
                      antonjazz_1
                        

                      Thank you again, Daniele!  This is a really cool demo. I'll have to check it out more when I have more time. As it turns out, I won't have to use script triggers at all, since the auto-entry solution comment responded with will work fine.


                      raybaudi wrote:

                       

                      Drag–and–Drop in FileMaker Pro 10 (white paper and demo)

                       

                      http://excelisys.com/web/downloads/index.php