12 Replies Latest reply on May 8, 2014 4:00 PM by keywords

    Simulate a double click


      What is the best way to script a double click? I have a picture in a small repeating container field that I want to double click and expand the selected picture to a larger size. Currently, I have the user clicking on the desired picture and press a view button. A double click is more intuitive.

        • 1. Re: Simulate a double click

          I will also need to know which container field repetition was clicked on.

          • 2. Re: Simulate a double click
            Mike Duncan

            You could use a couple global variables to save the name of the field (Get ( ActiveFieldName )) and repetition number ( get (activerepetitionnumber)) to test against.


            If both globals match, like


            $$myRep = Get ( ActiveRepetitionNumber ) and $$myField = Get ( ActiveFieldName )


            then you can export the field contents with $$myRep as the repetition. And also clear the global variables.


            In the "else" branch, set the global variables.

            • 3. Re: Simulate a double click

              Add an on entry script trigger to the field to run the script the View button is using. You may need to use the function Get(ActiveRepetitionNumber) to get the results you want.


              Repeating fields are often a poor choice because they require some kludgy workarounds. A related table is generally better.

              • 4. Re: Simulate a double click


                If I use an On Entry trigger, I am now in the field and can no longer double click.



                Yea, repeating fields are a pain, but I was lazy when I worked on this portion of the database. My earlier container fields (in other parts of the program) only required 1 repetition and when I needed to store more than 1 picture per record, I just changed it to a repeating field. No new scripting required. Lazy.



                Here is my entire scenario.

                I have a ERP system that manages business operations from sales estimating through invoicing and everything in between (eg, sales orders, work orders, inventory, purchasing, all the usual stuff). Each "module" has an area for "Attachments". That is, a place to store images of client po's, signed sale order acknowledgements, pics of an inventory item, etc.). Some modules need only 1 container, many need more than 1.

                The user drags his image into the container field and also has the option of selecting an image in a container field and coping it or moving it or deleting it. He can also click onto the container field and click a "View" button to enlarge/print it.

                I find myself double clicking the container field to view it because that is how most other applications behave. It is the natural thing to do.


                So, I would like to use the container field like any other field and also be able to double click it to enlarge the picture. I need an On Double Click trigger.

                • 5. Re: Simulate a double click

                  You can probably do this with some tricky scripting...


                  I can imagine doing it with an OnEntryTrigger and an OnTimer script.


                  The onEntryTrigger runs a script that checks to see if a variable  (say, $click) is set.


                  If so, it commits and Views the image and runs a blank Install onTimer.


                  If not, it sets the $click variable and runs an Install OnTimer script step with a delay of, say, .5 seconds.


                  The OnTimer script simply clears the variable and then runs a blank Install onTimer script step, preventing a loop.


                  Does that make sense? You can capture the "double click" with a variable and use an onTimer script step to clear that variable if the second click doesn't happen in time.

                  • 6. Re: Simulate a double click

                    Here is a custom function I use to detect double clicks.  I adapted from a routine I found elsewhere, I don't remember where.


                    It takes two parameters,  1) UniqueID = a unique item reference, such as a record ID, and 2) ClickSpeed = the delay time between clicks (optional).  It returns TRUE or FALSE. Hope it helpl


                    Let (

                    [  TimeNow = Get(CurrentTimeUTCMilliseconds);

                       ClickWindow = If(IsEmpty(ClickSpeed);300;ClickSpeed);

                       $$DblClickUniqueID = If($$DblClickUniqueID  ≠ UniqueID;UniqueID;"");

                       $$FirstClick = If((GetAsNumber(TimeNow) - GetAsNumber($$FirstClick)) > GetAsNumber(ClickWindow);TimeNow;"")


                       IsEmpty($$DblClickUniqueID) and IsEmpty($$FirstClick)


                    • 7. Re: Simulate a double click
                      Mike Duncan

                      Kyle, when I tested it, part of the script that was triggered was a go to field [] step to get back out of the field.

                      • 8. Re: Simulate a double click

                        Here is where I am currently. The script below runs on an On Entry trigger.



                        If [ Get ( CurrentTimeUTCMilliseconds ) - $$DoubleClickTimeStamp > 500 ]

                          Set Variable [ $$DoubleClickTimeStamp; Value:Get ( CurrentTimeUTCMilliseconds ) ]

                          Set Variable [ $FieldName; Value:Get ( ScriptParameter ) ]
                        Commit Records/Requests
                          Pause/Resume Script
                        [ Duration (seconds): 1 ]

                          Show Custom Dialog [ Message: $FieldName; Default Button: “OK”, Commit: “Yes” ]

                          Exit Script [ ]

                        End If

                        Commit Records/Requests

                        Show Custom Dialog [ Message: "Double clicked"; Default Button: “OK”, Commit: “Yes” ]

                        Halt Script


                        The Show dialogs are for development purposes only.

                        It does detect single and double clicks well enough (a 1 second delay on the single click is too long though)


                        I havent yet figured out how to enter the correct field and repitition on a single click though.

                        • 9. Re: Simulate a double click

                          This is what I did. Works reasonable well. Thank for all the help and inspiration.




                          If [ $$Ignore = 1 ]

                          #••••••••••••• Stop trigger loop.

                          Set Variable [ $$Ignore; Value:0 ]

                          Halt Script End If

                          If [ Get ( CurrentTimeUTCMilliseconds ) - $$DoubleClickTimeStamp > 500 ]
                          #••••••••••••• Object was single clicked. Go to Object passed as script parameter.
                          Set Variable [ $$DoubleClickTimeStamp; Value:Get ( CurrentTimeUTCMilliseconds ) ]

                          Set Variable [ $ObjectName; Value:GetValue ( Get ( ScriptParameter ) ; 1 ) ]
                          Set Variable [ $RepetitionNumber; Value:GetValue ( Get ( ScriptParameter ) ; 2 ) ]

                          Commit Records/Requests
                          Pause/Resume Script
                          [ Duration (seconds): .3 ]
                          Set Variable [ $$Ignore; Value:1 ]
                          Go to Object [ Object Name: $ObjectName; Repetition: $RepetitionNumber ]
                          Halt Script

                          End If

                          #••••••••••••• Object was double clicked. Copy container and show in new window.

                          Perform Script [ “Get Current Window Size” ]

                          Copy[ ]

                          [ Select ]
                          New Window [ Name: "Picture"; Style: Document; Close: “Yes”; Minimize: “Yes”; Maximize: “Yes”; Zoom Control Area: “Yes”; Resize:

                          “Yes” ]

                          Go to Layout [ “Picture_Portrait” (_MiscTable) ]

                          Show All Records
                          Omit Record
                          Show Omitted Only

                          Move/Resize Window [ Current Window; Height: 900; Width: 690 ]

                          Paste [ _MiscTable::x_GlobalPicture ]

                          [ Select; No style ]

                          If [ GetWidth ( _MiscTable::x_GlobalPicture ) > GetHeight ( _MiscTable::x_GlobalPicture ) ]

                          Go to Layout [ “Picture_Landscape” (_MiscTable) ]
                          Move/Resize Window [ Current Window; Height: 770; Width: 1000 ]

                          End If
                          Move/Resize Window
                          [ Current Window; Top: Max(0;$$Top+(($$Height-Get ( WindowHeight ))/2)); Left: Max(0;$$left+(($$width-Get

                          ( WindowWidth ))/2)) ]

                          Commit Records/Requests Pause/Resume Script [ Indefinitely ]

                          Close Window [ Current Window ]



                          BTW, how do I copy and paste a script to a post?


                          • 10. Re: Simulate a double click

                            Print to PDF?


                            -- sent from my iPhone4 --

                            Beverly Voth


                            • 11. Re: Simulate a double click

                              That's what I did. Seems like I see scripts posted that look cleaner than what I posted here.

                              • 12. Re: Simulate a double click

                                Although you appear to have resolved this one you miht like to take a look at the following:  http://www.nightwing.com.au/FileMaker/demos8/demo810.html


                                Ray Cologon posted this double-click demo way back but it's no doubt upgradable to current practice.