MCPcopy Create free account
hub / github.com/axmolengine/axmol / onGLFWMouseCallBack

Method onGLFWMouseCallBack

core/platform/RenderViewImpl.cpp:1095–1138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1093}
1094
1095void RenderViewImpl::onGLFWMouseCallBack(GLFWwindow* /*window*/, int button, int action, int /*modify*/)
1096{
1097 if (!_isTouchDevice)
1098 {
1099 if (GLFW_MOUSE_BUTTON_LEFT == button)
1100 {
1101 if (GLFW_PRESS == action)
1102 {
1103 _captured = true;
1104 if (this->getViewPortRect().equals(ax::Rect::ZERO) ||
1105 this->getViewPortRect().containsPoint(Vec2(_mouseX, _mouseY)))
1106 {
1107 intptr_t id = 0;
1108 this->handleTouchesBegin(1, &id, &_mouseX, &_mouseY);
1109 }
1110 }
1111 else if (GLFW_RELEASE == action)
1112 {
1113 if (_captured)
1114 {
1115 _captured = false;
1116 intptr_t id = 0;
1117 this->handleTouchesEnd(1, &id, &_mouseX, &_mouseY);
1118 }
1119 }
1120 }
1121 }
1122
1123 float cursorX = transformInputX(_mouseX);
1124 float cursorY = transformInputY(_mouseY);
1125
1126 if (GLFW_PRESS == action)
1127 {
1128 EventMouse event(EventMouse::MouseEventType::MOUSE_DOWN);
1129 event.setMouseInfo(cursorX, cursorY, static_cast<ax::EventMouse::MouseButton>(button));
1130 Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
1131 }
1132 else if (GLFW_RELEASE == action)
1133 {
1134 EventMouse event(EventMouse::MouseEventType::MOUSE_UP);
1135 event.setMouseInfo(cursorX, cursorY, static_cast<ax::EventMouse::MouseButton>(button));
1136 Director::getInstance()->getEventDispatcher()->dispatchEvent(&event);
1137 }
1138}
1139
1140void RenderViewImpl::onGLFWMouseMoveCallBack(GLFWwindow* window, double x, double y)
1141{

Callers 1

onGLFWMouseCallBackMethod · 0.45

Calls 8

transformInputYFunction · 0.85
getInstanceFunction · 0.85
handleTouchesBeginMethod · 0.80
handleTouchesEndMethod · 0.80
Vec2Function · 0.50
equalsMethod · 0.45
containsPointMethod · 0.45
dispatchEventMethod · 0.45

Tested by

no test coverage detected