Merge pull request #865 from AleziaKurdis/CreateAppCopyID

Create app: Entity List: "Copy ID" on menu and contextual menu.
This commit is contained in:
ksuprynowicz 2024-03-29 22:30:28 +01:00 committed by GitHub
commit f1475e49ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 43 additions and 8 deletions

View file

@ -351,6 +351,8 @@ var EntityListTool = function(shouldUseEditTabletApp, selectionManager) {
that.selectionManager.cutSelectedEntities(); that.selectionManager.cutSelectedEntities();
} else if (data.type === "copy") { } else if (data.type === "copy") {
that.selectionManager.copySelectedEntities(); that.selectionManager.copySelectedEntities();
} else if (data.type === "copyID") {
that.selectionManager.copyIdsFromSelectedEntities();
} else if (data.type === "paste") { } else if (data.type === "paste") {
that.selectionManager.pasteEntities(); that.selectionManager.pasteEntities();
} else if (data.type === "duplicate") { } else if (data.type === "duplicate") {

View file

@ -122,6 +122,12 @@
<div class = "menu-item-shortcut">Ctrl-C</div> <div class = "menu-item-shortcut">Ctrl-C</div>
</div> </div>
</button> </button>
<button class="menu-button" id="hmdcopyid" >
<div class = "menu-item">
<div class = "menu-item-caption">Copy ID(s)</div>
<div class = "menu-item-shortcut"></div>
</div>
</button>
<button class="menu-button" id="hmdpaste" > <button class="menu-button" id="hmdpaste" >
<div class = "menu-item"> <div class = "menu-item">
<div class = "menu-item-caption">Paste</div> <div class = "menu-item-caption">Paste</div>

View file

@ -1,6 +1,6 @@
// entityList.js // entityList.js
// //
// Created by Ryan Huffman on 19 Nov 2014 // Created by Ryan Huffman on November 19th, 2014
// Copyright 2014 High Fidelity, Inc. // Copyright 2014 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors. // Copyright 2020 Vircadia contributors.
// Copyright 2024 Overte e.V. // Copyright 2024 Overte e.V.
@ -328,6 +328,7 @@ function loaded() {
elToolsMenu = document.getElementById("tools"); elToolsMenu = document.getElementById("tools");
elMenuBackgroundOverlay = document.getElementById("menuBackgroundOverlay"); elMenuBackgroundOverlay = document.getElementById("menuBackgroundOverlay");
elHmdCopy = document.getElementById("hmdcopy"); elHmdCopy = document.getElementById("hmdcopy");
elHmdCopyID = document.getElementById("hmdcopyid");
elHmdCut = document.getElementById("hmdcut"); elHmdCut = document.getElementById("hmdcut");
elHmdPaste = document.getElementById("hmdpaste"); elHmdPaste = document.getElementById("hmdpaste");
elHmdDuplicate = document.getElementById("hmdduplicate"); elHmdDuplicate = document.getElementById("hmdduplicate");
@ -424,6 +425,10 @@ function loaded() {
EventBridge.emitWebEvent(JSON.stringify({ type: "copy" })); EventBridge.emitWebEvent(JSON.stringify({ type: "copy" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
}; };
elHmdCopyID.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: "copyID" }));
closeAllEntityListMenu();
};
elHmdCut.onclick = function() { elHmdCut.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: "cut" })); EventBridge.emitWebEvent(JSON.stringify({ type: "cut" }));
closeAllEntityListMenu(); closeAllEntityListMenu();
@ -822,6 +827,9 @@ function loaded() {
case "Copy": case "Copy":
EventBridge.emitWebEvent(JSON.stringify({ type: "copy" })); EventBridge.emitWebEvent(JSON.stringify({ type: "copy" }));
break; break;
case "Copy ID(s)":
EventBridge.emitWebEvent(JSON.stringify({ type: "copyID" }));
break;
case "Paste": case "Paste":
EventBridge.emitWebEvent(JSON.stringify({ type: "paste" })); EventBridge.emitWebEvent(JSON.stringify({ type: "paste" }));
break; break;
@ -862,6 +870,10 @@ function loaded() {
enabledContextMenuItems.push("Rename"); enabledContextMenuItems.push("Rename");
enabledContextMenuItems.push("Delete"); enabledContextMenuItems.push("Delete");
} }
if (selectedEntities.length !== 0) {
enabledContextMenuItems.push("Copy ID(s)");
}
entityListContextMenu.open(clickEvent, entityID, enabledContextMenuItems); entityListContextMenu.open(clickEvent, entityID, enabledContextMenuItems);
} }

View file

@ -1,9 +1,10 @@
// //
// entityListContextMenu.js // entityListContextMenu.js
// //
// exampleContextMenus.js was originally created by David Rowe on 22 Aug 2018. // exampleContextMenus.js was originally created by David Rowe on August 22nd, 2018.
// Modified to entityListContextMenu.js by Thijs Wenker on 10 Oct 2018 // Modified to entityListContextMenu.js by Thijs Wenker on October 10th, 2018
// Copyright 2018 High Fidelity, Inc. // Copyright 2018 High Fidelity, Inc.
// Copyright 2024 Overte e.V.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -137,6 +138,7 @@ EntityListContextMenu.prototype = {
this._addListItem("Cut"); this._addListItem("Cut");
this._addListItem("Copy"); this._addListItem("Copy");
this._addListItem("Copy ID(s)");
this._addListItem("Paste"); this._addListItem("Paste");
this._addListSeparator(); this._addListSeparator();
this._addListItem("Rename"); this._addListItem("Rename");

View file

@ -1,12 +1,12 @@
// //
// entitySelectionTool.js // entitySelectionTool.js
// //
// Created by Brad hefta-Gaub on 10/1/14. // Created by Brad hefta-Gaub on October 1st, 2014.
// Modified by Daniela Fontes * @DanielaFifo and Tiago Andrade @TagoWill on 4/7/2017 // Modified by Daniela Fontes * @DanielaFifo and Tiago Andrade @TagoWill on April 7th, 2017
// Modified by David Back on 1/9/2018 // Modified by David Back on January 9th, 2018
// Copyright 2014 High Fidelity, Inc. // Copyright 2014 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors // Copyright 2020 Vircadia contributors
// Copyright 2022-2023 Overte e.V. // Copyright 2022-2024 Overte e.V.
// //
// This script implements a class useful for building tools for editing entities. // This script implements a class useful for building tools for editing entities.
// //
@ -496,6 +496,18 @@ SelectionManager = (function() {
that.createApp.deleteSelectedEntities(); that.createApp.deleteSelectedEntities();
}; };
that.copyIdsFromSelectedEntities = function() {
if (that.selections.length === 0) {
audioFeedback.rejection();
} else if (that.selections.length === 1) {
Window.copyToClipboard(that.selections[0]);
audioFeedback.confirmation();
} else {
Window.copyToClipboard(JSON.stringify(that.selections));
audioFeedback.confirmation();
}
};
that.copySelectedEntities = function() { that.copySelectedEntities = function() {
var entityProperties = Entities.getMultipleEntityProperties(that.selections); var entityProperties = Entities.getMultipleEntityProperties(that.selections);
var entityHostTypes = Entities.getMultipleEntityProperties(that.selections, 'entityHostType'); var entityHostTypes = Entities.getMultipleEntityProperties(that.selections, 'entityHostType');

View file

@ -1776,6 +1776,7 @@ input#property-scale-button-reset {
display: none; display: none;
position: fixed; position: fixed;
color: #000000; color: #000000;
font-family: FiraSans-SemiBold;
background-color: #afafaf; background-color: #afafaf;
padding: 5px 0 5px 0; padding: 5px 0 5px 0;
cursor: default; cursor: default;
@ -1795,7 +1796,7 @@ input#property-scale-button-reset {
padding: 0 0; padding: 0 0;
} }
.context-menu li.disabled { .context-menu li.disabled {
color: #333333; color: #777777;
} }
.context-menu li.separator:hover, .context-menu li.disabled:hover { .context-menu li.separator:hover, .context-menu li.disabled:hover {
background-color: #afafaf; background-color: #afafaf;