overte-org / overte

Overte open source virtual worlds platform.
https://overte.org/
Other
138 stars 50 forks source link

PointerEvents don't report keyboard modifiers #808

Closed SilverfishVR closed 7 months ago

SilverfishVR commented 8 months ago

When using Entities.clickDownOnEntity, Entities.clickReleaseOnEntity, or Entities.holdingClickOnEntity, the keyboardModifiers property of the returned pointerEvent is always 0, even if a modifier key is pressed.

Seems like a bug to me, and makes it very complicated to detect something like "Shift+click". It is still possible, but you have to also register keyboard events and keep track of the modifier keys state.

Entities.clickDownOnEntity.connect(function clicky(clickedEntityID, event) {
   console.info("ClickDown event properties: ", JSON.stringify(event));
})

Logs all the pointerEvent correctly except keyboardModifieres which is always 0:

ClickDown event properties: {"type":"Press","id":1,"pos2D":{"x":-22.33271598815918,"y":11.494194030761719},"pos3D":{"x":7.227341651916504,"y":-11.495054244995117,"z":40.51707458496094},"normal":{"x":0.00003051851308555342,"y":1,"z":-0.00003064062548219226},"direction":{"x":-0.9338483214378357,"y":-0.20370860397815704,"z":0.2939901649951935},"button":"Primary","isPrimaryButton":true,"isLeftButton":true,"isPrimaryHeld":true,"isSecondaryHeld":false,"isTertiaryHeld":false,"keyboardModifiers":0}

daleglass commented 7 months ago

Needs testing if this happens on all platforms

SilverfishVR commented 7 months ago

Im on Win10

HifiExperiments commented 7 months ago

this was just never implemented but should be easy to fix, see EntityTreeRenderer::mousePressEvent etc. which all pass Qt::NoModifier: https://github.com/overte-org/overte/blob/f9b5c786fba5d9de5bf374189c18b0084c30e544/libraries/entities-renderer/src/EntityTreeRenderer.cpp#L915

they should all grab the modifiers from the QMouseEvent