From c5fc851bb7d39ab28d485554ce8559b66f2fedfc Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Sun, 30 Dec 2012 01:01:44 -0500 Subject: [PATCH] bug fix for swipe gesture detection (nil x or y) a complete_last_ev var is used to make sure the first argument to isSwipe() method has no nil x or y entry. --- frontend/ui/gesturedetector.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/frontend/ui/gesturedetector.lua b/frontend/ui/gesturedetector.lua index b31f656d9..11b963dca 100644 --- a/frontend/ui/gesturedetector.lua +++ b/frontend/ui/gesturedetector.lua @@ -269,7 +269,16 @@ function GestureDetector:panState(ev) DEBUG("in pan state...") if ev.id == -1 then -- end of pan, signal swipe gesture if necessary - swipe_direct = self:isSwipe(ev) + -- we need to construct a complete_last_ev because + -- the x or y of ev might be nil. + local complete_last_ev = self:deepCopyEv(ev) + if not complete_last_ev.x then + complete_last_ev.x = self.cur_x + end + if not complete_last_ev.y then + complete_last_ev.y = self.cur_y + end + swipe_direct = self:isSwipe(complete_last_ev) if swipe_direct then local start_pos = Geom:new{ x = self.first_ev.x,