bool Form::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta) { bool eventConsumed = false; for (size_t i = 0; i < __forms.size(); ++i) { Form* form = __forms[i]; GP_ASSERT(form); if (form->isEnabled()) { if (form->_node) { Vector3 point; if (form->projectPoint(x, y, &point)) { const Rectangle& bounds = form->getBounds(); if (form->getState() == Control::FOCUS || ((evt == Mouse::MOUSE_PRESS_LEFT_BUTTON || evt == Mouse::MOUSE_PRESS_MIDDLE_BUTTON || evt == Mouse::MOUSE_PRESS_RIGHT_BUTTON || evt == Mouse::MOUSE_WHEEL) && point.x >= bounds.x && point.x <= bounds.x + bounds.width && point.y >= bounds.y && point.y <= bounds.y + bounds.height)) { eventConsumed |= form->mouseEvent(evt, point.x - bounds.x, bounds.height - point.y - bounds.y, wheelDelta); } } } else { // Simply compare with the form's bounds. const Rectangle& bounds = form->getBounds(); if (form->getState() == Control::FOCUS || ((evt == Mouse::MOUSE_PRESS_LEFT_BUTTON || evt == Mouse::MOUSE_PRESS_MIDDLE_BUTTON || evt == Mouse::MOUSE_PRESS_RIGHT_BUTTON || evt == Mouse::MOUSE_WHEEL) && x >= bounds.x && x <= bounds.x + bounds.width && y >= bounds.y && y <= bounds.y + bounds.height)) { // Pass on the event's position relative to the form. eventConsumed |= form->mouseEvent(evt, x - bounds.x, y - bounds.y, wheelDelta); } } } } return eventConsumed; }
bool Form::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta) { for (size_t i = 0; i < __forms.size(); ++i) { Form* form = __forms[i]; GP_ASSERT(form); if (form->isEnabled() && form->isVisible()) { if (form->_node) { Vector3 point; if (form->projectPoint(x, y, &point)) { const Rectangle& bounds = form->getBounds(); if (shouldPropagateMouseEvent(form->getState(), evt, bounds, point.x, point.y)) { if (form->mouseEvent(evt, point.x - bounds.x, bounds.height - point.y - bounds.y, wheelDelta)) return true; } } } else { // Simply compare with the form's bounds. const Rectangle& bounds = form->getBounds(); if (shouldPropagateMouseEvent(form->getState(), evt, bounds, x, y)) { // Pass on the event's position relative to the form. if (form->mouseEvent(evt, x - bounds.x, y - bounds.y, wheelDelta)) return true; } } } } return false; }