Has anyone succeed in having a script branch based on single tap vs double tap on a button or field in FM GO?
If got this working --- Demo attached - works with clicks also of course
Yes, I've done this with having the first tap set a $$variable. The script checks to see if there is a value in the variable before it sets the value. if yes the script does the double tap action and then resets the variable back to empty. If no the script does the single tap action and sets the $$variable.
So far so good, but the $$variable need to be set back to empty after, say, .5 sec, Othwer wise you can/t dothe sigle tab, do somethig else, and thendo teh single tap a second time.
I think it needs an ontime script that clears the a variable after .5 sec, stops further execution of itself, and the does the single tap action
The tap script:
if variable is empty , sets it and invokes t timer script
If variable is set (means I am tapping again within 5. sec) it cears it and does the double tap action.
Does that sound right?
Sounds like you are on the right track. I'm not sure if the on timer script step will work for a fraction of a second. In my unofficial testing, it appears that you can enter a decimal but it will still only execute every second. I don't think setting it for 1 second should hurt anything. Also if you set the $$variable back to empty, quit the on timer script step.
I did a little more testing that now seems to indicate that a fraction of a second will work with the on timer script step.
Oliver, good job. I just downloaded this to my iPad. I think you need an Allow User Abort [off] step at the beginning of the script. Might also increase the interval slightly to accommodate slow double tappers.
That's a good idea in case the user taps somewhere else while the timer is running
Note if this is a field, and its contents are needed for the single tap script branch, you may need to store thatinfo in variables becauseyou have to exit the field so the second tap is captured with a feild entry trogger, and if that does not happen, and so the timer script executes to branch to the single tap option, you will no longer be in the field. Usually you would be able to reference the field's contents, but not in the case of repeating field or a field in portal -- in those cases the specifcs must be captured on the first tap.
An onTimer script may work, but what about setting the $var to a timestamp and comparing times?
With the Timestamp approach:
If a first click is detected the script has to pause to see if second click happens within say 1 sec. The script has to be on Button with "Halt Script" set, so any script running will halt.
Timestamps increment in whole seconds, so to recognize the second tap as such you need to test for a TS difference of more than one second -- a change of 1 second in the value of Get(currenttimestamp) can occur in a millisecond so the second click can otherwise easily look like the first click. So the a second click up to two seconds later can be inetrpted as a double click - The pause to await the second click can be as short as you like but that icreases the risk of a second click occuring while the One-click script branch is executing
If the "One click" branch of the script takes a few seconds or so to finish and the user clicks again, it will halt the execution with unpredictable results so an immediate layout change is needed in that branch. Whereas with the timer method script only the on timer script itself is halted. (Allow User Abort Off does not prevent a user hlting a script in this way)
It is also more complex than Timer method if you want to apply it to a field and use the field conteants in the script, and this will not be possible in the case of specific repetition.
My IOS case was a weekly appointment schedule using repeating fields to set up a grid. A single tap drills down to the meeting detail. A double tab cancels the meeting. The Timer methd works well for this.
Sounds like you have a working solution, but you can get milliseconds with the function Get ( UTCmSecs )
Thanks. That may com in handy. However, for me, me avoiding "Halt Scdript" gives the edge to the On Timer approach
Retrieving data ...