diff --git a/gui/controller.cpp b/gui/controller.cpp index b348b1f6be..6c6d44321a 100644 --- a/gui/controller.cpp +++ b/gui/controller.cpp @@ -53,6 +53,7 @@ namespace gui { m_focusedElement = l.front(); m_focusedElement->onTapStarted(pt); + m_LastTapCancelled = false; return true; } @@ -63,8 +64,11 @@ namespace gui { if (m_focusedElement) { - if (!m_focusedElement->roughHitTest(pt) || !m_focusedElement->hitTest(pt)) + if (!m_focusedElement->hitTest(pt)) + { m_focusedElement->onTapCancelled(pt); + m_LastTapCancelled = true; + } else m_focusedElement->onTapMoved(pt); @@ -79,8 +83,11 @@ namespace gui { if (m_focusedElement) { - m_focusedElement->onTapEnded(pt); + if (!m_LastTapCancelled) + m_focusedElement->onTapEnded(pt); + m_focusedElement.reset(); + m_LastTapCancelled = false; return true; } diff --git a/gui/controller.hpp b/gui/controller.hpp index 79439bac7a..f6b7e2c83f 100644 --- a/gui/controller.hpp +++ b/gui/controller.hpp @@ -60,6 +60,10 @@ namespace gui /// Screen, which is used to cache gui::Elements into display lists. yg::gl::Screen * m_CacheScreen; + /// Should we call the onTapEnded when the tap finished(we should + /// not if the tap was cancelled while moving). + bool m_LastTapCancelled; + public: /// Constructor with GestureDetector to route events from.