Merge pull request #5868 from dumganhar/iss4447

closed #4447: [Desktop] Can't receive touchEnded event when mouse up outside of window
This commit is contained in:
James Chen 2014-03-19 17:46:49 +08:00
commit 7ad17e1e69
1 changed files with 4 additions and 7 deletions

View File

@ -529,9 +529,9 @@ void GLView::onGLFWMouseCallBack(GLFWwindow* window, int button, int action, int
} }
else if(GLFW_RELEASE == action) else if(GLFW_RELEASE == action)
{ {
_captured = false; if (_captured)
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Point(_mouseX,_mouseY)))
{ {
_captured = false;
int id = 0; int id = 0;
this->handleTouchesEnd(1, &id, &_mouseX, &_mouseY); this->handleTouchesEnd(1, &id, &_mouseX, &_mouseY);
} }
@ -574,13 +574,10 @@ void GLView::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
} }
if (_captured) if (_captured)
{
if (this->getViewPortRect().equals(Rect::ZERO) || this->getViewPortRect().containsPoint(Point(_mouseX, _mouseY)))
{ {
int id = 0; int id = 0;
this->handleTouchesMove(1, &id, &_mouseX, &_mouseY); this->handleTouchesMove(1, &id, &_mouseX, &_mouseY);
} }
}
EventMouse event(EventMouse::MouseEventType::MOUSE_MOVE); EventMouse event(EventMouse::MouseEventType::MOUSE_MOVE);
//Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here //Because OpenGL and cocos2d-x uses different Y axis, we need to convert the coordinate here