mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:08:47 +02:00
PointerEvent will now relay keyboard modifiers
This commit is contained in:
parent
4aeed2093c
commit
792c7ff51f
6 changed files with 36 additions and 21 deletions
|
@ -693,8 +693,9 @@ static PointerEvent::Button toPointerButton(const QMouseEvent& event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay ray,
|
PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay ray,
|
||||||
RayToOverlayIntersectionResult rayPickResult, QMouseEvent* event, PointerEvent::EventType eventType) {
|
RayToOverlayIntersectionResult rayPickResult, QMouseEvent* event,
|
||||||
|
PointerEvent::EventType eventType) {
|
||||||
|
|
||||||
auto thisOverlay = std::dynamic_pointer_cast<Web3DOverlay>(overlay);
|
auto thisOverlay = std::dynamic_pointer_cast<Web3DOverlay>(overlay);
|
||||||
|
|
||||||
|
@ -704,10 +705,9 @@ PointerEvent Overlays::calculatePointerEvent(Overlay::Pointer overlay, PickRay r
|
||||||
auto dimensions = thisOverlay->getSize();
|
auto dimensions = thisOverlay->getSize();
|
||||||
|
|
||||||
glm::vec2 pos2D = projectOntoOverlayXYPlane(position, rotation, dimensions, ray, rayPickResult);
|
glm::vec2 pos2D = projectOntoOverlayXYPlane(position, rotation, dimensions, ray, rayPickResult);
|
||||||
PointerEvent pointerEvent(eventType, MOUSE_POINTER_ID,
|
|
||||||
pos2D, rayPickResult.intersection,
|
PointerEvent pointerEvent(eventType, MOUSE_POINTER_ID, pos2D, rayPickResult.intersection, rayPickResult.surfaceNormal,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
ray.direction, toPointerButton(*event), toPointerButtons(*event), event->modifiers());
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
|
||||||
|
|
||||||
return pointerEvent;
|
return pointerEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,9 +344,8 @@ void Web3DOverlay::handlePointerEvent(const PointerEvent& event) {
|
||||||
QList<QTouchEvent::TouchPoint> touchPoints;
|
QList<QTouchEvent::TouchPoint> touchPoints;
|
||||||
touchPoints.push_back(point);
|
touchPoints.push_back(point);
|
||||||
|
|
||||||
QTouchEvent* touchEvent = new QTouchEvent(type);
|
QTouchEvent* touchEvent = new QTouchEvent(type, &_touchDevice, event.getKeyboardModifiers());
|
||||||
touchEvent->setWindow(_webSurface->getWindow());
|
touchEvent->setWindow(_webSurface->getWindow());
|
||||||
touchEvent->setDevice(&_touchDevice);
|
|
||||||
touchEvent->setTarget(_webSurface->getRootItem());
|
touchEvent->setTarget(_webSurface->getRootItem());
|
||||||
touchEvent->setTouchPoints(touchPoints);
|
touchEvent->setTouchPoints(touchPoints);
|
||||||
touchEvent->setTouchPointStates(touchPointState);
|
touchEvent->setTouchPointStates(touchPointState);
|
||||||
|
|
|
@ -713,7 +713,8 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event) {
|
||||||
PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Press, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
toPointerButton(*event), toPointerButtons(*event),
|
||||||
|
Qt::NoModifier); // TODO -- check for modifier keys?
|
||||||
|
|
||||||
emit mousePressOnEntity(rayPickResult.entityID, pointerEvent);
|
emit mousePressOnEntity(rayPickResult.entityID, pointerEvent);
|
||||||
|
|
||||||
|
@ -753,7 +754,8 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
toPointerButton(*event), toPointerButtons(*event),
|
||||||
|
Qt::NoModifier); // TODO -- check for modifier keys?
|
||||||
|
|
||||||
emit mouseReleaseOnEntity(rayPickResult.entityID, pointerEvent);
|
emit mouseReleaseOnEntity(rayPickResult.entityID, pointerEvent);
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
|
@ -773,7 +775,8 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Release, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
toPointerButton(*event), toPointerButtons(*event),
|
||||||
|
Qt::NoModifier); // TODO -- check for modifier keys?
|
||||||
|
|
||||||
emit clickReleaseOnEntity(_currentClickingOnEntityID, pointerEvent);
|
emit clickReleaseOnEntity(_currentClickingOnEntityID, pointerEvent);
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
|
@ -803,7 +806,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) {
|
||||||
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
toPointerButton(*event), toPointerButtons(*event),
|
||||||
|
Qt::NoModifier); // TODO -- check for modifier keys?
|
||||||
|
|
||||||
emit mouseMoveOnEntity(rayPickResult.entityID, pointerEvent);
|
emit mouseMoveOnEntity(rayPickResult.entityID, pointerEvent);
|
||||||
|
|
||||||
|
@ -823,7 +827,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) {
|
||||||
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
toPointerButton(*event), toPointerButtons(*event),
|
||||||
|
Qt::NoModifier); // TODO -- check for modifier keys?
|
||||||
|
|
||||||
emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent);
|
emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent);
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
|
@ -864,7 +869,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) {
|
||||||
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
toPointerButton(*event), toPointerButtons(*event),
|
||||||
|
Qt::NoModifier); // TODO -- check for modifier keys?
|
||||||
|
|
||||||
emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent);
|
emit hoverLeaveEntity(_currentHoverOverEntityID, pointerEvent);
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
|
@ -883,7 +889,8 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event) {
|
||||||
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
PointerEvent pointerEvent(PointerEvent::Move, MOUSE_POINTER_ID,
|
||||||
pos2D, rayPickResult.intersection,
|
pos2D, rayPickResult.intersection,
|
||||||
rayPickResult.surfaceNormal, ray.direction,
|
rayPickResult.surfaceNormal, ray.direction,
|
||||||
toPointerButton(*event), toPointerButtons(*event));
|
toPointerButton(*event), toPointerButtons(*event),
|
||||||
|
Qt::NoModifier); // TODO -- check for modifier keys?
|
||||||
|
|
||||||
emit holdingClickOnEntity(_currentClickingOnEntityID, pointerEvent);
|
emit holdingClickOnEntity(_currentClickingOnEntityID, pointerEvent);
|
||||||
if (_entitiesScriptEngine) {
|
if (_entitiesScriptEngine) {
|
||||||
|
|
|
@ -25,9 +25,9 @@ PointerEvent::PointerEvent() {
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerEvent::PointerEvent(EventType type, uint32_t id,
|
PointerEvent::PointerEvent(EventType type, uint32_t id,
|
||||||
const glm::vec2& pos2D, const glm::vec3& pos3D,
|
const glm::vec2& pos2D, const glm::vec3& pos3D,
|
||||||
const glm::vec3& normal, const glm::vec3& direction,
|
const glm::vec3& normal, const glm::vec3& direction,
|
||||||
Button button, uint32_t buttons) :
|
Button button, uint32_t buttons, Qt::KeyboardModifiers keyboardModifiers) :
|
||||||
_type(type),
|
_type(type),
|
||||||
_id(id),
|
_id(id),
|
||||||
_pos2D(pos2D),
|
_pos2D(pos2D),
|
||||||
|
@ -35,7 +35,8 @@ PointerEvent::PointerEvent(EventType type, uint32_t id,
|
||||||
_normal(normal),
|
_normal(normal),
|
||||||
_direction(direction),
|
_direction(direction),
|
||||||
_button(button),
|
_button(button),
|
||||||
_buttons(buttons)
|
_buttons(buttons),
|
||||||
|
_keyboardModifiers(keyboardModifiers)
|
||||||
{
|
{
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -119,6 +120,8 @@ QScriptValue PointerEvent::toScriptValue(QScriptEngine* engine, const PointerEve
|
||||||
obj.setProperty("isSecondaryHeld", areFlagsSet(event._buttons, SecondaryButton));
|
obj.setProperty("isSecondaryHeld", areFlagsSet(event._buttons, SecondaryButton));
|
||||||
obj.setProperty("isTertiaryHeld", areFlagsSet(event._buttons, TertiaryButton));
|
obj.setProperty("isTertiaryHeld", areFlagsSet(event._buttons, TertiaryButton));
|
||||||
|
|
||||||
|
obj.setProperty("keyboardModifiers", QScriptValue(event.getKeyboardModifiers()));
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,5 +177,7 @@ void PointerEvent::fromScriptValue(const QScriptValue& object, PointerEvent& eve
|
||||||
if (tertiary) {
|
if (tertiary) {
|
||||||
event._buttons |= TertiaryButton;
|
event._buttons |= TertiaryButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event._keyboardModifiers = (Qt::KeyboardModifiers)(object.property("keyboardModifiers").toUInt32());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#ifndef hifi_PointerEvent_h
|
#ifndef hifi_PointerEvent_h
|
||||||
#define hifi_PointerEvent_h
|
#define hifi_PointerEvent_h
|
||||||
|
|
||||||
|
#include <Qt>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
#include <QScriptValue>
|
#include <QScriptValue>
|
||||||
|
@ -35,7 +37,7 @@ public:
|
||||||
PointerEvent(EventType type, uint32_t id,
|
PointerEvent(EventType type, uint32_t id,
|
||||||
const glm::vec2& pos2D, const glm::vec3& pos3D,
|
const glm::vec2& pos2D, const glm::vec3& pos3D,
|
||||||
const glm::vec3& normal, const glm::vec3& direction,
|
const glm::vec3& normal, const glm::vec3& direction,
|
||||||
Button button, uint32_t buttons);
|
Button button, uint32_t buttons, Qt::KeyboardModifiers keyboardModifiers);
|
||||||
|
|
||||||
static QScriptValue toScriptValue(QScriptEngine* engine, const PointerEvent& event);
|
static QScriptValue toScriptValue(QScriptEngine* engine, const PointerEvent& event);
|
||||||
static void fromScriptValue(const QScriptValue& object, PointerEvent& event);
|
static void fromScriptValue(const QScriptValue& object, PointerEvent& event);
|
||||||
|
@ -50,6 +52,7 @@ public:
|
||||||
const glm::vec3& getDirection() const { return _direction; }
|
const glm::vec3& getDirection() const { return _direction; }
|
||||||
Button getButton() const { return _button; }
|
Button getButton() const { return _button; }
|
||||||
uint32_t getButtons() const { return _buttons; }
|
uint32_t getButtons() const { return _buttons; }
|
||||||
|
Qt::KeyboardModifiers getKeyboardModifiers() const { return _keyboardModifiers; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventType _type;
|
EventType _type;
|
||||||
|
@ -61,6 +64,7 @@ private:
|
||||||
|
|
||||||
Button _button { NoButtons }; // button assosiated with this event, (if type is Press, this will be the button that is pressed)
|
Button _button { NoButtons }; // button assosiated with this event, (if type is Press, this will be the button that is pressed)
|
||||||
uint32_t _buttons { NoButtons }; // the current state of all the buttons.
|
uint32_t _buttons { NoButtons }; // the current state of all the buttons.
|
||||||
|
Qt::KeyboardModifiers _keyboardModifiers { Qt::NoModifier };
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(PointerEvent)
|
Q_DECLARE_METATYPE(PointerEvent)
|
||||||
|
|
|
@ -2064,7 +2064,7 @@ SelectionDisplay = (function() {
|
||||||
});
|
});
|
||||||
Overlays.editOverlay(grabberPointLightL, {
|
Overlays.editOverlay(grabberPointLightL, {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
Overlays.editOverlay(grabberPointLightR, {
|
Overlays.editOverlay(grabberPointLightR, {
|
||||||
visible: false
|
visible: false
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue