mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 10:17:27 +02:00
[ui] Viewer3D: fix wrong keyboard modifier state
Keyboard Actions are never deactivated when focus is lost, leading to picking being enabled on a single click when Control was pressed in the 3D viewer and focus was lost to another Item. * keep track of focus loss inside the DefaultCameraController * use it to disable picking while Keyboard has not been pressed back in the 3D viewer * do the same for 'moving' state with Alt modifier
This commit is contained in:
parent
7a8e1c689f
commit
f6365c5607
2 changed files with 19 additions and 3 deletions
|
@ -12,8 +12,9 @@ Entity {
|
||||||
property real translateSpeed: 75.0
|
property real translateSpeed: 75.0
|
||||||
property real tiltSpeed: 500.0
|
property real tiltSpeed: 500.0
|
||||||
property real panSpeed: 500.0
|
property real panSpeed: 500.0
|
||||||
property bool moving: pressed || actionAlt.active
|
property bool moving: pressed || (actionAlt.active && keyboardHandler._pressed)
|
||||||
readonly property alias controlPressed: actionControl.active
|
property alias focus: keyboardHandler.focus
|
||||||
|
readonly property bool pickingActive: actionControl.active && keyboardHandler._pressed
|
||||||
|
|
||||||
readonly property alias pressed: mouseHandler._pressed
|
readonly property alias pressed: mouseHandler._pressed
|
||||||
signal mousePressed(var mouse)
|
signal mousePressed(var mouse)
|
||||||
|
@ -40,6 +41,20 @@ Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KeyboardHandler {
|
||||||
|
id: keyboardHandler
|
||||||
|
sourceDevice: keyboardSourceDevice
|
||||||
|
property bool _pressed
|
||||||
|
|
||||||
|
// When focus is lost while pressing a key, the corresponding action
|
||||||
|
// stays active, even when it's released.
|
||||||
|
// Handle this issue manually by keeping an additional _pressed state
|
||||||
|
// which is cleared when focus changes (used for 'pickingActive' property).
|
||||||
|
onFocusChanged: if(!focus) _pressed = false
|
||||||
|
onPressed: _pressed = true
|
||||||
|
onReleased: _pressed = false
|
||||||
|
}
|
||||||
|
|
||||||
LogicalDevice {
|
LogicalDevice {
|
||||||
id: cameraControlDevice
|
id: cameraControlDevice
|
||||||
actions: [
|
actions: [
|
||||||
|
|
|
@ -193,6 +193,7 @@ FocusScope {
|
||||||
DefaultCameraController {
|
DefaultCameraController {
|
||||||
id: cameraController
|
id: cameraController
|
||||||
camera: mainCamera
|
camera: mainCamera
|
||||||
|
focus: scene3D.activeFocus
|
||||||
onMousePressed: {
|
onMousePressed: {
|
||||||
scene3D.forceActiveFocus()
|
scene3D.forceActiveFocus()
|
||||||
if(mouse.button == Qt.LeftButton)
|
if(mouse.button == Qt.LeftButton)
|
||||||
|
@ -273,7 +274,7 @@ FocusScope {
|
||||||
id: picker
|
id: picker
|
||||||
// Triangle picking is expensive
|
// Triangle picking is expensive
|
||||||
// Only activate it when a double click may happen or when the 'Control' key is pressed
|
// Only activate it when a double click may happen or when the 'Control' key is pressed
|
||||||
enabled: cameraController.controlPressed || doubleClickTimer.running
|
enabled: cameraController.pickingActive || doubleClickTimer.running
|
||||||
hoverEnabled: false
|
hoverEnabled: false
|
||||||
onPressed: {
|
onPressed: {
|
||||||
if(pick.button == Qt.LeftButton)
|
if(pick.button == Qt.LeftButton)
|
||||||
|
|
Loading…
Add table
Reference in a new issue