From 6302ae6bd5d204b91a5a2773a3cb1d8d738c20b7 Mon Sep 17 00:00:00 2001 From: Menithal Date: Wed, 15 Feb 2017 19:48:29 +0200 Subject: [PATCH 01/16] Changed AudioScope Hotkeys, Allowing User Hotkeys AudioScope Open Hotkey changed from Ctrl + P to Ctrl + Alt + P and Audioscope Pause Hotkey changed from Ctrl + Shift + P to Ctrl + Shift + Alt + P --- interface/src/Menu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index acf97ad5f7..431fe0638a 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -577,7 +577,7 @@ Menu::Menu() { nodeList.data(), SLOT(toggleSendNewerDSConnectVersion(bool))); #endif - + // Developer >> Tests >>> MenuWrapper* testMenu = developerMenu->addMenu("Tests"); addActionToQMenuAndActionHash(testMenu, MenuOption::RunClientScriptTests, 0, dialogsManager.data(), SLOT(showTestingResults())); @@ -628,9 +628,9 @@ Menu::Menu() { auto scope = DependencyManager::get(); MenuWrapper* audioScopeMenu = audioDebugMenu->addMenu("Audio Scope"); - addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScope, Qt::CTRL | Qt::Key_P, false, + addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScope, Qt::CTRL | Qt::ALT | Qt::Key_P, false, scope.data(), SLOT(toggle())); - addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopePause, Qt::CTRL | Qt::SHIFT | Qt::Key_P, false, + addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopePause, Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_P, false, scope.data(), SLOT(togglePause())); addDisabledActionAndSeparator(audioScopeMenu, "Display Frames"); From 7b02d1073a08cca23b904f2c1848b38fe7a9ca5a Mon Sep 17 00:00:00 2001 From: Menithal Date: Wed, 15 Feb 2017 19:49:31 +0200 Subject: [PATCH 02/16] Added a generic Window Notification for Feedback This allows to use the existing Pop-up notifications for generic notification messages --- scripts/system/notifications.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index 3ae071c7e3..b2ebb1fd46 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -521,6 +521,9 @@ function onEditError(msg) { createNotification(wordWrap(msg), NotificationType.EDIT_ERROR); } +function onNotify(msg) { + createNotification(wordWrap(msg), NotificationType.UNKNOWN); // Needs a generic notification system for user feedback, thus using this +} function onSnapshotTaken(pathStillSnapshot, pathAnimatedSnapshot, notify) { if (notify) { @@ -637,6 +640,7 @@ Window.domainConnectionRefused.connect(onDomainConnectionRefused); Window.snapshotTaken.connect(onSnapshotTaken); Window.processingGif.connect(processingGif); Window.notifyEditError = onEditError; +Window.notify = onNotify; setup(); From 655c49d9c00f68d8a6f6814d819ceffd1032ce7a Mon Sep 17 00:00:00 2001 From: Menithal Date: Wed, 15 Feb 2017 19:50:15 +0200 Subject: [PATCH 03/16] edit.js: started to work on Parenting via hotkey --- scripts/system/edit.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index da39edf8ba..5476e1208f 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1096,7 +1096,30 @@ function recursiveDelete(entities, childrenList) { Entities.deleteEntity(entityID); } } +function parentSelectedEntities() { + if (SelectionManager.hasSelection()) { + SelectionManager.saveProperties(); + var selectedEntities = selectionManager.selections; + if (selectedEntities.length <= 1) { + Window.notifyEditError("You must have multiple objects selected in order to parent them"); + return; + } + var lastEntityId = selectedEntities[selectedEntities.length] + selectedEntities.some(function (id, index) { + if (lastId === id) { + return false; + } + Entities.editProperties(id, {parentID: lastId}) + return true; + }); + SelectionManager.clearSelections(); + + Window.notify("Entities Parented"); + } else { + Window.notifyEditError("You have nothing selected") + } +} function deleteSelectedEntities() { if (SelectionManager.hasSelection()) { selectedParticleEntity = 0; @@ -1324,6 +1347,8 @@ Controller.keyReleaseEvent.connect(function (event) { }); grid.setPosition(newPosition); } + } else if (event.text === 'p' && event.isCtrl) { + parentSelectedEntities(); } }); From c3021ae60d917bb7c50df1757d07f6e5f46aa25b Mon Sep 17 00:00:00 2001 From: Menithal Date: Wed, 15 Feb 2017 22:21:29 +0200 Subject: [PATCH 04/16] Fixing Menu Items for Parenting / Unparenting --- scripts/system/edit.js | 78 ++++++++++++++++++++++++++++++++---------- 1 file changed, 59 insertions(+), 19 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 5476e1208f..afb171e936 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -838,7 +838,6 @@ function setupModelMenus() { }); modelMenuAddedDelete = true; } - Menu.addMenuItem({ menuName: "Edit", menuItemName: "Entity List...", @@ -846,6 +845,23 @@ function setupModelMenus() { afterItem: "Entities", grouping: "Advanced" }); + + Menu.addMenuItem({ + menuName: "Edit", + menuItemName: "Parent Entity to Last", + shortcutKey: "CTRL+P", + afterItem: "Entity List...", + grouping: "Advanced" + }); + + Menu.addMenuItem({ + menuName: "Edit", + menuItemName: "Unparent Entity", + afterItem: "Entity List...", + shortcutKey: "CTRL+SHIFT+P", + afterItem: "Entity List...", + grouping: "Advanced" + }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Large Models", @@ -953,6 +969,8 @@ function cleanupModelMenus() { Menu.removeMenuItem("Edit", "Delete"); } + Menu.removeMenuItem("Edit", "Parent"); + Menu.removeMenuItem("Edit", "Unparent"); Menu.removeMenuItem("Edit", "Entity List..."); Menu.removeMenuItem("Edit", "Allow Selecting of Large Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Small Models"); @@ -1096,28 +1114,42 @@ function recursiveDelete(entities, childrenList) { Entities.deleteEntity(entityID); } } -function parentSelectedEntities() { +function unparentSelectedEntities() { + print("unparenting2 Selected Entities"); if (SelectionManager.hasSelection()) { - SelectionManager.saveProperties(); var selectedEntities = selectionManager.selections; - if (selectedEntities.length <= 1) { - Window.notifyEditError("You must have multiple objects selected in order to parent them"); - return; - } - - var lastEntityId = selectedEntities[selectedEntities.length] - selectedEntities.some(function (id, index) { - if (lastId === id) { - return false; - } - Entities.editProperties(id, {parentID: lastId}) + selectedEntities.forEach(function (id, index) { + Entities.editEntity(id, {parentID: null}) return true; }); - SelectionManager.clearSelections(); - Window.notify("Entities Parented"); + Window.notify("Entities Unparented"); + } + +} +function parentSelectedEntities() { + print("parenting selected Entities"); + if (SelectionManager.hasSelection()) { + var selectedEntities = selectionManager.selections; + if (selectedEntities.length <= 1) { + Window.notifyEditError("You must have multiple objects selected in order to parent them"); + return; + } + var lastEntityId = selectedEntities[selectedEntities.length-1]; + + print("last " + lastEntityId); + selectedEntities.forEach(function (id, index) { + if (lastEntityId !== id) { + print("iterating2 " + id); + + // OK time to check why this breaks! + Entities.editEntity(id, {parentID: lastEntityId}) + } + }); + + Window.notify("Entities Parented"); } else { - Window.notifyEditError("You have nothing selected") + Window.notifyEditError("You have nothing selected") } } function deleteSelectedEntities() { @@ -1182,6 +1214,10 @@ function handeMenuEvent(menuItem) { Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights")); } else if (menuItem === "Delete") { deleteSelectedEntities(); + } else if (menuItem === "Parent") { + parentSelectedEntities(); + } else if (menuItem === "Unparent") { + unparentSelectedEntities(); } else if (menuItem === "Export Entities") { if (!selectionManager.hasSelection()) { Window.notifyEditError("No entities have been selected."); @@ -1347,8 +1383,12 @@ Controller.keyReleaseEvent.connect(function (event) { }); grid.setPosition(newPosition); } - } else if (event.text === 'p' && event.isCtrl) { - parentSelectedEntities(); + } else if (event.text === 'p' && event.isControl ) { + if (event.isShifted) { + unparentSelectedEntities(); + } else { + parentSelectedEntities(); + } } }); From ff2c344eaaab3e7e6d121415fb8530277ea46428 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 16 Feb 2017 09:04:58 +0200 Subject: [PATCH 05/16] Migrated Audioscope Hotkeys to use F2 instead of P Apparently ctrl + shift + P which was planned to be used in the client for unparenting entities did not work out, as the command went out of the main view. Migrating to ctrl + F2 and ctrl + alt + F2 --- interface/src/Menu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 431fe0638a..3ff5e00c06 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -628,9 +628,9 @@ Menu::Menu() { auto scope = DependencyManager::get(); MenuWrapper* audioScopeMenu = audioDebugMenu->addMenu("Audio Scope"); - addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScope, Qt::CTRL | Qt::ALT | Qt::Key_P, false, + addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScope, Qt::CTRL | Qt::Key_F2, false, scope.data(), SLOT(toggle())); - addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopePause, Qt::CTRL | Qt::ALT | Qt::SHIFT | Qt::Key_P, false, + addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopePause, Qt::CTRL | Qt::ALT | Qt::Key_F2, false, scope.data(), SLOT(togglePause())); addDisabledActionAndSeparator(audioScopeMenu, "Display Frames"); From d96f95a7e9b52765137c2c8d1d27eb93f9eba776 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 16 Feb 2017 10:05:59 +0200 Subject: [PATCH 06/16] Updated edit.js and selection tool Last selected entity will now be yellow instead of orange --- scripts/system/edit.js | 8 +------ .../system/libraries/entitySelectionTool.js | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index afb171e936..1c76e03efd 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1115,7 +1115,6 @@ function recursiveDelete(entities, childrenList) { } } function unparentSelectedEntities() { - print("unparenting2 Selected Entities"); if (SelectionManager.hasSelection()) { var selectedEntities = selectionManager.selections; selectedEntities.forEach(function (id, index) { @@ -1128,7 +1127,6 @@ function unparentSelectedEntities() { } function parentSelectedEntities() { - print("parenting selected Entities"); if (SelectionManager.hasSelection()) { var selectedEntities = selectionManager.selections; if (selectedEntities.length <= 1) { @@ -1137,16 +1135,12 @@ function parentSelectedEntities() { } var lastEntityId = selectedEntities[selectedEntities.length-1]; - print("last " + lastEntityId); selectedEntities.forEach(function (id, index) { if (lastEntityId !== id) { - print("iterating2 " + id); - // OK time to check why this breaks! Entities.editEntity(id, {parentID: lastEntityId}) } }); - Window.notify("Entities Parented"); } else { Window.notifyEditError("You have nothing selected") @@ -1384,7 +1378,7 @@ Controller.keyReleaseEvent.connect(function (event) { grid.setPosition(newPosition); } } else if (event.text === 'p' && event.isControl ) { - if (event.isShifted) { + if (event.isAlt) { unparentSelectedEntities(); } else { parentSelectedEntities(); diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index b9bae72d14..146dc1894b 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -1170,14 +1170,14 @@ SelectionDisplay = (function() { // determine which bottom corner we are closest to /*------------------------------ example: - + BRF +--------+ BLF | | | | BRN +--------+ BLN - + * - + ------------------------------*/ var cameraPosition = Camera.getPosition(); @@ -2189,8 +2189,12 @@ SelectionDisplay = (function() { offset = Vec3.multiplyQbyV(properties.rotation, offset); var boxPosition = Vec3.sum(properties.position, offset); + var color = {red: 255, green: 153, blue: 0}; + if (i >= selectionManager.selections.length - 1) color = {red: 255, green: 255, blue: 0}; + Overlays.editOverlay(selectionBoxes[i], { position: boxPosition, + color: color, rotation: properties.rotation, dimensions: properties.dimensions, visible: true, @@ -2395,7 +2399,7 @@ SelectionDisplay = (function() { if (wantDebug) { print("Start Elevation: " + translateXZTool.startingElevation + ", elevation: " + elevation); } - if ((translateXZTool.startingElevation > 0.0 && elevation < MIN_ELEVATION) || + if ((translateXZTool.startingElevation > 0.0 && elevation < MIN_ELEVATION) || (translateXZTool.startingElevation < 0.0 && elevation > -MIN_ELEVATION)) { if (wantDebug) { print("too close to horizon!"); @@ -3857,7 +3861,7 @@ SelectionDisplay = (function() { }; that.mousePressEvent = function(event) { - var wantDebug = false; + var wantDebug = false; if (!event.isLeftButton && !that.triggered) { // if another mouse button than left is pressed ignore it return false; @@ -3883,7 +3887,7 @@ SelectionDisplay = (function() { if (result.intersects) { - + if (wantDebug) { print("something intersects... "); print(" result.overlayID:" + result.overlayID + "[" + overlayNames[result.overlayID] + "]"); @@ -3983,7 +3987,7 @@ SelectionDisplay = (function() { if (wantDebug) { print("rotate handle case..."); } - + // After testing our stretch handles, then check out rotate handles Overlays.editOverlay(yawHandle, { @@ -4205,7 +4209,7 @@ SelectionDisplay = (function() { case selectionBox: activeTool = translateXZTool; translateXZTool.pickPlanePosition = result.intersection; - translateXZTool.greatestDimension = Math.max(Math.max(SelectionManager.worldDimensions.x, SelectionManager.worldDimensions.y), + translateXZTool.greatestDimension = Math.max(Math.max(SelectionManager.worldDimensions.x, SelectionManager.worldDimensions.y), SelectionManager.worldDimensions.z); if (wantDebug) { print("longest dimension: " + translateXZTool.greatestDimension); @@ -4214,7 +4218,7 @@ SelectionDisplay = (function() { translateXZTool.startingElevation = translateXZTool.elevation(pickRay.origin, translateXZTool.pickPlanePosition); print(" starting elevation: " + translateXZTool.startingElevation); } - + mode = translateXZTool.mode; activeTool.onBegin(event); somethingClicked = 'selectionBox'; From 7a5665ff4f2370f1cae6b018cb2568cd07a3aa59 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 16 Feb 2017 10:09:19 +0200 Subject: [PATCH 07/16] Hotkey change to make AudioScope similar to earlier --- interface/src/Menu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 3ff5e00c06..c131367aee 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -630,7 +630,7 @@ Menu::Menu() { MenuWrapper* audioScopeMenu = audioDebugMenu->addMenu("Audio Scope"); addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScope, Qt::CTRL | Qt::Key_F2, false, scope.data(), SLOT(toggle())); - addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopePause, Qt::CTRL | Qt::ALT | Qt::Key_F2, false, + addCheckableActionToQMenuAndActionHash(audioScopeMenu, MenuOption::AudioScopePause, Qt::CTRL | Qt::SHIFT | Qt::Key_F2, false, scope.data(), SLOT(togglePause())); addDisabledActionAndSeparator(audioScopeMenu, "Display Frames"); From afbf4bc30f53cd63efc2df1ab5ebfa14de7ec65d Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 16 Feb 2017 10:52:42 +0200 Subject: [PATCH 08/16] Fixed Parenting/Unparenting Menu Removal and Binding --- scripts/system/edit.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 1c76e03efd..b83ca9a896 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -969,8 +969,8 @@ function cleanupModelMenus() { Menu.removeMenuItem("Edit", "Delete"); } - Menu.removeMenuItem("Edit", "Parent"); - Menu.removeMenuItem("Edit", "Unparent"); + Menu.removeMenuItem("Edit", "Parent Entity to Last"); + Menu.removeMenuItem("Edit", "Unparent Entity"); Menu.removeMenuItem("Edit", "Entity List..."); Menu.removeMenuItem("Edit", "Allow Selecting of Large Models"); Menu.removeMenuItem("Edit", "Allow Selecting of Small Models"); @@ -1134,10 +1134,8 @@ function parentSelectedEntities() { return; } var lastEntityId = selectedEntities[selectedEntities.length-1]; - selectedEntities.forEach(function (id, index) { if (lastEntityId !== id) { - // OK time to check why this breaks! Entities.editEntity(id, {parentID: lastEntityId}) } }); @@ -1208,9 +1206,9 @@ function handeMenuEvent(menuItem) { Entities.setLightsArePickable(Menu.isOptionChecked("Allow Selecting of Lights")); } else if (menuItem === "Delete") { deleteSelectedEntities(); - } else if (menuItem === "Parent") { + } else if (menuItem === "Parent Entity to Last") { parentSelectedEntities(); - } else if (menuItem === "Unparent") { + } else if (menuItem === "Unparent Entity") { unparentSelectedEntities(); } else if (menuItem === "Export Entities") { if (!selectionManager.hasSelection()) { @@ -1378,7 +1376,7 @@ Controller.keyReleaseEvent.connect(function (event) { grid.setPosition(newPosition); } } else if (event.text === 'p' && event.isControl ) { - if (event.isAlt) { + if (event.isShifted) { unparentSelectedEntities(); } else { parentSelectedEntities(); From f5d266a56253703e35a8baf78159479ccac22ac7 Mon Sep 17 00:00:00 2001 From: Menithal Date: Fri, 17 Feb 2017 23:28:28 +0200 Subject: [PATCH 09/16] Updated --- scripts/system/edit.js | 26 ++++++++++++------- scripts/system/html/entityList.html | 3 +++ scripts/system/html/entityProperties.html | 3 ++- scripts/system/html/js/parentingHotkey.js | 12 +++++++++ .../system/libraries/entitySelectionTool.js | 4 +-- 5 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 scripts/system/html/js/parentingHotkey.js diff --git a/scripts/system/edit.js b/scripts/system/edit.js index b83ca9a896..d759760893 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -859,7 +859,6 @@ function setupModelMenus() { menuItemName: "Unparent Entity", afterItem: "Entity List...", shortcutKey: "CTRL+SHIFT+P", - afterItem: "Entity List...", grouping: "Advanced" }); Menu.addMenuItem({ @@ -1003,6 +1002,9 @@ Script.scriptEnding.connect(function () { Overlays.deleteOverlay(importingSVOImageOverlay); Overlays.deleteOverlay(importingSVOTextOverlay); + + Controller.keyReleaseEvent.disconnect(keyReleaseEvent); + Controller.keyPressEvent.disconnect(keyPressEvent); }); var lastOrientation = null; @@ -1121,10 +1123,8 @@ function unparentSelectedEntities() { Entities.editEntity(id, {parentID: null}) return true; }); - Window.notify("Entities Unparented"); } - } function parentSelectedEntities() { if (SelectionManager.hasSelection()) { @@ -1335,13 +1335,12 @@ Window.svoImportRequested.connect(importSVO); Menu.menuItemEvent.connect(handeMenuEvent); -Controller.keyPressEvent.connect(function (event) { +var keyPressEvent = function (event) { if (isActive) { cameraManager.keyPressEvent(event); } -}); - -Controller.keyReleaseEvent.connect(function (event) { +}; +var keyReleaseEvent = function (event) { if (isActive) { cameraManager.keyReleaseEvent(event); } @@ -1375,14 +1374,16 @@ Controller.keyReleaseEvent.connect(function (event) { }); grid.setPosition(newPosition); } - } else if (event.text === 'p' && event.isControl ) { + } else if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) { if (event.isShifted) { unparentSelectedEntities(); } else { parentSelectedEntities(); } } -}); +}; +Controller.keyReleaseEvent.connect(keyReleaseEvent); +Controller.keyPressEvent.connect(keyPressEvent); function recursiveAdd(newParentID, parentData) { var children = parentData.children; @@ -1632,6 +1633,10 @@ var PropertiesTool = function (opts) { } pushCommandForSelections(); selectionManager._update(); + } else if(data.type === 'parent') { + parentSelectedEntities(); + } else if(data.type === 'unparent') { + unparentSelectedEntities(); } else if(data.type === 'saveUserData'){ //the event bridge and json parsing handle our avatar id string differently. var actualID = data.id.split('"')[1]; @@ -1889,6 +1894,9 @@ var PopupMenu = function () { for (var i = 0; i < overlays.length; i++) { Overlays.deleteOverlay(overlays[i]); } + Controller.mousePressEvent.disconnect(self.mousePressEvent); + Controller.mouseMoveEvent.disconnect(self.mouseMoveEvent); + Controller.mouseReleaseEvent.disconnect(self.mouseReleaseEvent); } Controller.mousePressEvent.connect(self.mousePressEvent); diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index 197d8f550a..67d1973fa7 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -16,6 +16,7 @@ +
@@ -89,6 +90,8 @@ + +
No entities found in view within a 100 meter radius. Try moving to a different location and refreshing.
diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index b11127b26c..84c8a15dd3 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -22,6 +22,7 @@ +
@@ -61,7 +62,7 @@
- +

diff --git a/scripts/system/html/js/parentingHotkey.js b/scripts/system/html/js/parentingHotkey.js new file mode 100644 index 0000000000..c17dae01fe --- /dev/null +++ b/scripts/system/html/js/parentingHotkey.js @@ -0,0 +1,12 @@ +var keyReleaseEvent = function (event) { + if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) { + if (event.isShifted) { + EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); + } else { + EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' })); + } + } +}; + +window.onkeypress = keyReleaseEvent; +Controller.keyReleaseEvent.connect(keyReleaseEvent); diff --git a/scripts/system/libraries/entitySelectionTool.js b/scripts/system/libraries/entitySelectionTool.js index 146dc1894b..13f61dfd80 100644 --- a/scripts/system/libraries/entitySelectionTool.js +++ b/scripts/system/libraries/entitySelectionTool.js @@ -2189,8 +2189,8 @@ SelectionDisplay = (function() { offset = Vec3.multiplyQbyV(properties.rotation, offset); var boxPosition = Vec3.sum(properties.position, offset); - var color = {red: 255, green: 153, blue: 0}; - if (i >= selectionManager.selections.length - 1) color = {red: 255, green: 255, blue: 0}; + var color = {red: 255, green: 128, blue: 0}; + if (i >= selectionManager.selections.length - 1) color = {red: 255, green: 255, blue: 64}; Overlays.editOverlay(selectionBoxes[i], { position: boxPosition, From dcbe3c622db92d2e5729813392a9c483c5ae1c22 Mon Sep 17 00:00:00 2001 From: Menithal Date: Sat, 18 Feb 2017 11:51:19 +0200 Subject: [PATCH 10/16] Added Hotkey Listening to the webview Ctrl + P and Ctrl + Shift + P are now available even if the edit window has been selected --- scripts/system/edit.js | 13 +++---- scripts/system/html/entityList.html | 2 - scripts/system/html/entityProperties.html | 1 - scripts/system/html/js/entityList.js | 44 ++++++++++++---------- scripts/system/html/js/entityProperties.js | 16 ++++++-- scripts/system/html/js/gridControls.js | 11 +++++- scripts/system/html/js/parentingHotkey.js | 12 ------ 7 files changed, 52 insertions(+), 47 deletions(-) delete mode 100644 scripts/system/html/js/parentingHotkey.js diff --git a/scripts/system/edit.js b/scripts/system/edit.js index d759760893..d0236ce993 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1374,12 +1374,6 @@ var keyReleaseEvent = function (event) { }); grid.setPosition(newPosition); } - } else if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) { - if (event.isShifted) { - unparentSelectedEntities(); - } else { - parentSelectedEntities(); - } } }; Controller.keyReleaseEvent.connect(keyReleaseEvent); @@ -1586,6 +1580,7 @@ var PropertiesTool = function (opts) { print('Edit.js received web event that was not valid json.') return; } + print(JSON.stringify(data)) var i, properties, dY, diff, newPosition; if (data.type === "print") { if (data.message) { @@ -1924,7 +1919,11 @@ var particleExplorerTool = new ParticleExplorerTool(); var selectedParticleEntity = 0; entityListTool.webView.webEventReceived.connect(function (data) { data = JSON.parse(data); - if (data.type === "selectionUpdate") { + if(data.type === 'parent') { + parentSelectedEntities(); + } else if(data.type === 'unparent') { + unparentSelectedEntities(); + } else if (data.type === "selectionUpdate") { var ids = data.entityIds; if (ids.length === 1) { if (Entities.getEntityProperties(ids[0], "type").type === "ParticleEffect") { diff --git a/scripts/system/html/entityList.html b/scripts/system/html/entityList.html index 67d1973fa7..3cb79353f9 100644 --- a/scripts/system/html/entityList.html +++ b/scripts/system/html/entityList.html @@ -16,7 +16,6 @@ -
@@ -91,7 +90,6 @@ -
No entities found in view within a 100 meter radius. Try moving to a different location and refreshing.
diff --git a/scripts/system/html/entityProperties.html b/scripts/system/html/entityProperties.html index 84c8a15dd3..cc73d71517 100644 --- a/scripts/system/html/entityProperties.html +++ b/scripts/system/html/entityProperties.html @@ -22,7 +22,6 @@ -
diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 1af9c1e1d6..53d2d9030b 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -26,7 +26,7 @@ debugPrint = function (message) { }; function loaded() { - openEventBridge(function() { + openEventBridge(function() { entityList = new List('entity-list', { valueNames: ['name', 'type', 'url', 'locked', 'visible'], page: MAX_ITEMS}); entityList.clear(); elEntityTable = document.getElementById("entity-table"); @@ -48,7 +48,7 @@ function loaded() { elNoEntitiesInView = document.getElementById("no-entities-in-view"); elNoEntitiesRadius = document.getElementById("no-entities-radius"); elEntityTableScroll = document.getElementById("entity-table-scroll"); - + document.getElementById("entity-name").onclick = function() { setSortColumn('name'); }; @@ -90,7 +90,7 @@ function loaded() { selection = selection.concat(selectedEntities); } else if (clickEvent.shiftKey && selectedEntities.length > 0) { var previousItemFound = -1; - var clickedItemFound = -1; + var clickedItemFound = -1; for (var entity in entityList.visibleItems) { if (clickedItemFound === -1 && this.dataset.entityId == entityList.visibleItems[entity].values().id) { clickedItemFound = entity; @@ -113,11 +113,11 @@ function loaded() { selection = selection.concat(betweenItems, selectedEntities); } } - + selectedEntities = selection; - + this.className = 'selected'; - + EventBridge.emitWebEvent(JSON.stringify({ type: "selectionUpdate", focus: false, @@ -126,7 +126,7 @@ function loaded() { refreshFooter(); } - + function onRowDoubleClicked() { EventBridge.emitWebEvent(JSON.stringify({ type: "selectionUpdate", @@ -134,7 +134,7 @@ function loaded() { entityIds: [this.dataset.entityId], })); } - + const BYTES_PER_MEGABYTE = 1024 * 1024; function decimalMegabytes(number) { @@ -173,7 +173,7 @@ function loaded() { currentElement.onclick = onRowClicked; currentElement.ondblclick = onRowDoubleClicked; }); - + if (refreshEntityListTimer) { clearTimeout(refreshEntityListTimer); } @@ -183,13 +183,13 @@ function loaded() { item.values({ name: name, url: filename, locked: locked, visible: visible }); } } - + function clearEntities() { entities = {}; entityList.clear(); refreshFooter(); } - + var elSortOrder = { name: document.querySelector('#entity-name .sort-order'), type: document.querySelector('#entity-type .sort-order'), @@ -215,12 +215,12 @@ function loaded() { entityList.sort(currentSortColumn, { order: currentSortOrder }); } setSortColumn('type'); - + function refreshEntities() { clearEntities(); EventBridge.emitWebEvent(JSON.stringify({ type: 'refresh' })); } - + function refreshFooter() { if (selectedEntities.length > 1) { elFooter.firstChild.nodeValue = selectedEntities.length + " entities selected"; @@ -239,7 +239,7 @@ function loaded() { entityList.search(elFilter.value); refreshFooter(); } - + function updateSelectedEntities(selectedIDs) { var notFound = false; for (var id in entities) { @@ -262,7 +262,7 @@ function loaded() { return notFound; } - + elRefresh.onclick = function() { refreshEntities(); } @@ -282,7 +282,7 @@ function loaded() { EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' })); refreshEntities(); } - + document.addEventListener("keydown", function (keyDownEvent) { if (keyDownEvent.target.nodeName === "INPUT") { return; @@ -292,8 +292,15 @@ function loaded() { EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' })); refreshEntities(); } + if (keyDownEvent.keyCode === 80 && keyDownEvent.ctrlKey) { + if (keyDownEvent.shiftKey) { + EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); + } else { + EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' })); + } + } }, false); - + var isFilterInView = false; var FILTER_IN_VIEW_ATTRIBUTE = "pressed"; elNoEntitiesInView.style.display = "none"; @@ -320,7 +327,7 @@ function loaded() { if (window.EventBridge !== undefined) { EventBridge.scriptEventReceived.connect(function(data) { data = JSON.parse(data); - + if (data.type === "clearEntityList") { clearEntities(); } else if (data.type == "selectionUpdate") { @@ -426,4 +433,3 @@ function loaded() { event.preventDefault(); }, false); } - diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index 8879c0f34e..ab8a3f7c85 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -273,7 +273,7 @@ function updateCheckedSubProperty(propertyName, propertyValue, subPropertyElemen propertyValue += subPropertyString + ','; } } else { - // We've unchecked, so remove + // We've unchecked, so remove propertyValue = propertyValue.replace(subPropertyString + ",", ""); } @@ -780,7 +780,7 @@ function loaded() { if (lastEntityID !== '"' + properties.id + '"' && lastEntityID !== null && editor !== null) { saveJSONUserData(true); } - //the event bridge and json parsing handle our avatar id string differently. + //the event bridge and json parsing handle our avatar id string differently. lastEntityID = '"' + properties.id + '"'; elID.innerHTML = properties.id; @@ -1390,7 +1390,7 @@ function loaded() { elZoneFlyingAllowed.addEventListener('change', createEmitCheckedPropertyUpdateFunction('flyingAllowed')); elZoneGhostingAllowed.addEventListener('change', createEmitCheckedPropertyUpdateFunction('ghostingAllowed')); elZoneFilterURL.addEventListener('change', createEmitTextPropertyUpdateFunction('filterURL')); - + var voxelVolumeSizeChangeFunction = createEmitVec3PropertyUpdateFunction( 'voxelVolumeSize', elVoxelVolumeSizeX, elVoxelVolumeSizeY, elVoxelVolumeSizeZ); elVoxelVolumeSizeX.addEventListener('change', voxelVolumeSizeChangeFunction); @@ -1441,7 +1441,15 @@ function loaded() { })); }); - + document.addEventListener("keydown", function (keyDown) { + if (keyDown.keyCode === 80 && keyDown.ctrlKey) { + if (keyDown.shiftKey) { + EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); + } else { + EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' })); + } + } + }); window.onblur = function() { // Fake a change event var ev = document.createEvent("HTMLEvents"); diff --git a/scripts/system/html/js/gridControls.js b/scripts/system/html/js/gridControls.js index a245ed4cda..75052414ee 100644 --- a/scripts/system/html/js/gridControls.js +++ b/scripts/system/html/js/gridControls.js @@ -131,10 +131,17 @@ function loaded() { EventBridge.emitWebEvent(JSON.stringify({ type: 'init' })); }); - + document.addEventListener("keydown", function (keyDown) { + if (keyDown.keyCode === 80 && keyDown.ctrlKey) { + if (keyDown.shiftKey) { + EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); + } else { + EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' })); + } + } + }) // Disable right-click context menu which is not visible in the HMD and makes it seem like the app has locked document.addEventListener("contextmenu", function (event) { event.preventDefault(); }, false); } - diff --git a/scripts/system/html/js/parentingHotkey.js b/scripts/system/html/js/parentingHotkey.js deleted file mode 100644 index c17dae01fe..0000000000 --- a/scripts/system/html/js/parentingHotkey.js +++ /dev/null @@ -1,12 +0,0 @@ -var keyReleaseEvent = function (event) { - if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) { - if (event.isShifted) { - EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); - } else { - EventBridge.emitWebEvent(JSON.stringify({ type: 'parent' })); - } - } -}; - -window.onkeypress = keyReleaseEvent; -Controller.keyReleaseEvent.connect(keyReleaseEvent); From 0df6305f901e24ab1b3f4d3028f4c169059cb8e9 Mon Sep 17 00:00:00 2001 From: Menithal Date: Sat, 18 Feb 2017 18:22:01 +0200 Subject: [PATCH 11/16] Revert removal of hotkey from js event --- scripts/system/edit.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index d0236ce993..688fabab8b 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -849,7 +849,6 @@ function setupModelMenus() { Menu.addMenuItem({ menuName: "Edit", menuItemName: "Parent Entity to Last", - shortcutKey: "CTRL+P", afterItem: "Entity List...", grouping: "Advanced" }); @@ -858,7 +857,6 @@ function setupModelMenus() { menuName: "Edit", menuItemName: "Unparent Entity", afterItem: "Entity List...", - shortcutKey: "CTRL+SHIFT+P", grouping: "Advanced" }); Menu.addMenuItem({ @@ -1374,6 +1372,12 @@ var keyReleaseEvent = function (event) { }); grid.setPosition(newPosition); } + } else if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) { + if (event.isShifted) { + unparentSelectedEntities(); + } else { + parentSelectedEntities(); + } } }; Controller.keyReleaseEvent.connect(keyReleaseEvent); From f3c806e91090c720e4f3841600f7933d44258a7e Mon Sep 17 00:00:00 2001 From: Menithal Date: Sat, 18 Feb 2017 18:33:00 +0200 Subject: [PATCH 12/16] Revert of hotkey detection, removed menu hotkeys - Holding hotkeys will no longer spam parent events rapidly, detects only the release --- scripts/system/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 688fabab8b..bc76489c41 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1372,7 +1372,7 @@ var keyReleaseEvent = function (event) { }); grid.setPosition(newPosition); } - } else if (event.text === 'p' && event.isControl && !event.isAutoRepeat ) { + } else if (event.key === 80 && event.isControl && !event.isAutoRepeat ) { if (event.isShifted) { unparentSelectedEntities(); } else { From 2a4b493de560049bf34f2e179cca4970a830a7c7 Mon Sep 17 00:00:00 2001 From: Menithal Date: Sun, 19 Feb 2017 18:24:56 +0200 Subject: [PATCH 13/16] Changed order on Menu --- scripts/system/edit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index bc76489c41..61bbd23180 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -856,14 +856,14 @@ function setupModelMenus() { Menu.addMenuItem({ menuName: "Edit", menuItemName: "Unparent Entity", - afterItem: "Entity List...", + afterItem: "Parent Entity to Last", grouping: "Advanced" }); Menu.addMenuItem({ menuName: "Edit", menuItemName: "Allow Selecting of Large Models", shortcutKey: "CTRL+META+L", - afterItem: "Entity List...", + afterItem: "Unparent Entity", isCheckable: true, isChecked: true, grouping: "Advanced" From d9f86612de72cb10004d70ae68db4e06669650fb Mon Sep 17 00:00:00 2001 From: Menithal Date: Sun, 19 Feb 2017 20:18:11 +0200 Subject: [PATCH 14/16] Fixed view toggle, Added new Notifications - View Toggle now only toggles if no other modifiers are pressed - More notification, and cases for notification - Parenting to existing parent - Unparenting when there is no parent - Unparenting single entities --- interface/src/Application.cpp | 10 ++++--- scripts/system/edit.js | 54 ++++++++++++++++++++++++++++------- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 488e97b5e6..bfc5be29e7 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2886,10 +2886,12 @@ void Application::keyPressEvent(QKeyEvent* event) { } break; case Qt::Key_P: { - bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson); - Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !isFirstPersonChecked); - Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, isFirstPersonChecked); - cameraMenuChanged(); + if (!(isShifted || isMeta || isOption)) { + bool isFirstPersonChecked = Menu::getInstance()->isOptionChecked(MenuOption::FirstPerson); + Menu::getInstance()->setIsOptionChecked(MenuOption::FirstPerson, !isFirstPersonChecked); + Menu::getInstance()->setIsOptionChecked(MenuOption::ThirdPerson, isFirstPersonChecked); + cameraMenuChanged(); + } break; } diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 61bbd23180..7731edd622 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1116,30 +1116,64 @@ function recursiveDelete(entities, childrenList) { } function unparentSelectedEntities() { if (SelectionManager.hasSelection()) { - var selectedEntities = selectionManager.selections; - selectedEntities.forEach(function (id, index) { - Entities.editEntity(id, {parentID: null}) - return true; - }); - Window.notify("Entities Unparented"); + var selectedEntities = selectionManager.selections; + var parentCheck = false; + + if (selectedEntities.length < 1) { + Window.notifyEditError("You must have an entity selected inorder to unparent it."); + return; + } + selectedEntities.forEach(function (id, index) { + var parentId = Entities.getEntityProperties(id, ["parentID"]).parentID; + if (parentId !== null && parentId.length > 0 && parentId !== "{00000000-0000-0000-0000-000000000000}") { + parentCheck = true; + } + Entities.editEntity(id, {parentID: null}) + return true; + }); + if (parentCheck) { + if (selectedEntities.length > 1) { + Window.notify("Entities unparented"); + } else { + Window.notify("Entity unparented"); + } + } else { + if (selectedEntities.length > 1) { + Window.notify("Selected Entities have no parents"); + } else { + Window.notify("Selected Entity does not have a parent"); + } + } + } else { + Window.notifyEditError("You have nothing selected to unparent"); } } function parentSelectedEntities() { if (SelectionManager.hasSelection()) { var selectedEntities = selectionManager.selections; if (selectedEntities.length <= 1) { - Window.notifyEditError("You must have multiple objects selected in order to parent them"); - return; + Window.notifyEditError("You must have multiple entities selected in order to parent them"); + return; } + var parentCheck = false; var lastEntityId = selectedEntities[selectedEntities.length-1]; selectedEntities.forEach(function (id, index) { if (lastEntityId !== id) { + var parentId = Entities.getEntityProperties(id, ["parentID"]).parentID; + if (parentId !== lastEntityId) { + parentCheck = true; + } Entities.editEntity(id, {parentID: lastEntityId}) } }); - Window.notify("Entities Parented"); + + if(parentCheck) { + Window.notify("Entities parented"); + }else { + Window.notify("Entities are already parented to last"); + } } else { - Window.notifyEditError("You have nothing selected") + Window.notifyEditError("You have nothing selected to parent"); } } function deleteSelectedEntities() { From b1639ee3aafb07c96e1e516c74446bbe99737a9e Mon Sep 17 00:00:00 2001 From: Matti Lahtinen Date: Mon, 27 Feb 2017 23:40:06 +0200 Subject: [PATCH 15/16] Removed a Stray Print json that would spam logs. --- scripts/system/edit.js | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 7731edd622..bfa5ee478b 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -1618,7 +1618,6 @@ var PropertiesTool = function (opts) { print('Edit.js received web event that was not valid json.') return; } - print(JSON.stringify(data)) var i, properties, dY, diff, newPosition; if (data.type === "print") { if (data.message) { From 9c31f66b75b4ee5618d38378a128dbf1971ceda4 Mon Sep 17 00:00:00 2001 From: Menithal Date: Thu, 2 Mar 2017 21:39:56 +0200 Subject: [PATCH 16/16] Addressed CR of 9684 --- scripts/system/edit.js | 3 ++- scripts/system/html/js/entityList.js | 3 ++- scripts/system/html/js/entityProperties.js | 4 ++-- scripts/system/html/js/gridControls.js | 4 +++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/system/edit.js b/scripts/system/edit.js index 7731edd622..16a49dbf41 100644 --- a/scripts/system/edit.js +++ b/scripts/system/edit.js @@ -56,6 +56,7 @@ selectionManager.addEventListener(function () { lightOverlayManager.updatePositions(); }); +const KEY_P = 80; //Key code for letter p used for Parenting hotkey. var DEGREES_TO_RADIANS = Math.PI / 180.0; var RADIANS_TO_DEGREES = 180.0 / Math.PI; var epsilon = 0.001; @@ -1406,7 +1407,7 @@ var keyReleaseEvent = function (event) { }); grid.setPosition(newPosition); } - } else if (event.key === 80 && event.isControl && !event.isAutoRepeat ) { + } else if (event.key === KEY_P && event.isControl && !event.isAutoRepeat ) { if (event.isShifted) { unparentSelectedEntities(); } else { diff --git a/scripts/system/html/js/entityList.js b/scripts/system/html/js/entityList.js index 53d2d9030b..914fc6525e 100644 --- a/scripts/system/html/js/entityList.js +++ b/scripts/system/html/js/entityList.js @@ -19,6 +19,7 @@ const VISIBLE_GLYPH = ""; const TRANSPARENCY_GLYPH = ""; const SCRIPT_GLYPH = "k"; const DELETE = 46; // Key code for the delete key. +const KEY_P = 80; // Key code for letter p used for Parenting hotkey. const MAX_ITEMS = Number.MAX_VALUE; // Used to set the max length of the list of discovered entities. debugPrint = function (message) { @@ -292,7 +293,7 @@ function loaded() { EventBridge.emitWebEvent(JSON.stringify({ type: 'delete' })); refreshEntities(); } - if (keyDownEvent.keyCode === 80 && keyDownEvent.ctrlKey) { + if (keyDownEvent.keyCode === KEY_P && keyDownEvent.ctrlKey) { if (keyDownEvent.shiftKey) { EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); } else { diff --git a/scripts/system/html/js/entityProperties.js b/scripts/system/html/js/entityProperties.js index ab8a3f7c85..c51293f4bc 100644 --- a/scripts/system/html/js/entityProperties.js +++ b/scripts/system/html/js/entityProperties.js @@ -24,7 +24,7 @@ var ICON_FOR_TYPE = { } var EDITOR_TIMEOUT_DURATION = 1500; - +const KEY_P = 80; //Key code for letter p used for Parenting hotkey. var colorPickers = []; var lastEntityID = null; debugPrint = function(message) { @@ -1442,7 +1442,7 @@ function loaded() { }); document.addEventListener("keydown", function (keyDown) { - if (keyDown.keyCode === 80 && keyDown.ctrlKey) { + if (keyDown.keyCode === KEY_P && keyDown.ctrlKey) { if (keyDown.shiftKey) { EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); } else { diff --git a/scripts/system/html/js/gridControls.js b/scripts/system/html/js/gridControls.js index 75052414ee..be4271788e 100644 --- a/scripts/system/html/js/gridControls.js +++ b/scripts/system/html/js/gridControls.js @@ -6,6 +6,8 @@ // Distributed under the Apache License, Version 2.0. // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +const KEY_P = 80; //Key code for letter p used for Parenting hotkey. + function loaded() { openEventBridge(function() { elPosY = document.getElementById("horiz-y"); @@ -132,7 +134,7 @@ function loaded() { EventBridge.emitWebEvent(JSON.stringify({ type: 'init' })); }); document.addEventListener("keydown", function (keyDown) { - if (keyDown.keyCode === 80 && keyDown.ctrlKey) { + if (keyDown.keyCode === KEY_P && keyDown.ctrlKey) { if (keyDown.shiftKey) { EventBridge.emitWebEvent(JSON.stringify({ type: 'unparent' })); } else {