
Just because there's no handler for an event doesn't mean it isn't there -- it just means it isn't handled. So yes, mousedowns do happen but if you don't have a script that catches them, they do nothing. For the swipe, the mousedown event needs to record the position on screen so that the mouseup has something to compare it to. So you do need your mousedown handler, but you don't need to change anything in it.
The mouseUp handler only compares the two locations to see how far apart they are and if it's more than 50 pixels, it considers that a swipe has occured. If so, it takes action. But there are no instructions in there about what to do if it isn't a swipe, so nothing happens in that case. So all you need to do is add instructions for the instances where the mouse went up but the difference is less than 50 pixels; i.e., it's a tap, not a swipe. (By the way, I think 50 pixels is too big. I use 10 or 20 usually. It's up to you.)
So you need something like this in your mouseUp:
Code: Select all
on mouseUp
if abs(the mouseH - sStartH) > 50 then -- it's a swipe
if the mouseH < sStartH then
goNext
else
goPrev
end if
else -- it's a tap
-- do whatever you need to do here to respond to the tap in the field
end if
end mouseUp
Your example omitted the script local variable, but nothing will work without it so make sure you include that at the top of the field script:
Code: Select all
local sStartH
on mouseDown
put the mouseH into sStartH
end mouseDown
on mouseUp
if abs(the mouseH - sStartH) > 50 then -- it's a swipe
if the mouseH < sStartH then
goNext
else
goPrev
end if
else -- it's a tap
-- do whatever you need to do here to respond to the tap in the field
end if
end mouseUp