Skip to content

Commit

Permalink
Merge pull request overte-org#865 from AleziaKurdis/CreateAppCopyID
Browse files Browse the repository at this point in the history
Create app: Entity List: "Copy ID" on menu and contextual menu.
  • Loading branch information
ksuprynowicz authored Mar 29, 2024
2 parents c41c2de + 7c8044d commit f1475e4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
2 changes: 2 additions & 0 deletions scripts/system/create/entityList/entityList.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ var EntityListTool = function(shouldUseEditTabletApp, selectionManager) {
that.selectionManager.cutSelectedEntities();
} else if (data.type === "copy") {
that.selectionManager.copySelectedEntities();
} else if (data.type === "copyID") {
that.selectionManager.copyIdsFromSelectedEntities();
} else if (data.type === "paste") {
that.selectionManager.pasteEntities();
} else if (data.type === "duplicate") {
Expand Down
6 changes: 6 additions & 0 deletions scripts/system/create/entityList/html/entityList.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
<div class = "menu-item-shortcut">Ctrl-C</div>
</div>
</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" >
<div class = "menu-item">
<div class = "menu-item-caption">Paste</div>
Expand Down
14 changes: 13 additions & 1 deletion scripts/system/create/entityList/html/js/entityList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// entityList.js
//
// Created by Ryan Huffman on 19 Nov 2014
// Created by Ryan Huffman on November 19th, 2014
// Copyright 2014 High Fidelity, Inc.
// Copyright 2020 Vircadia contributors.
// Copyright 2024 Overte e.V.
Expand Down Expand Up @@ -328,6 +328,7 @@ function loaded() {
elToolsMenu = document.getElementById("tools");
elMenuBackgroundOverlay = document.getElementById("menuBackgroundOverlay");
elHmdCopy = document.getElementById("hmdcopy");
elHmdCopyID = document.getElementById("hmdcopyid");
elHmdCut = document.getElementById("hmdcut");
elHmdPaste = document.getElementById("hmdpaste");
elHmdDuplicate = document.getElementById("hmdduplicate");
Expand Down Expand Up @@ -424,6 +425,10 @@ function loaded() {
EventBridge.emitWebEvent(JSON.stringify({ type: "copy" }));
closeAllEntityListMenu();
};
elHmdCopyID.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: "copyID" }));
closeAllEntityListMenu();
};
elHmdCut.onclick = function() {
EventBridge.emitWebEvent(JSON.stringify({ type: "cut" }));
closeAllEntityListMenu();
Expand Down Expand Up @@ -822,6 +827,9 @@ function loaded() {
case "Copy":
EventBridge.emitWebEvent(JSON.stringify({ type: "copy" }));
break;
case "Copy ID(s)":
EventBridge.emitWebEvent(JSON.stringify({ type: "copyID" }));
break;
case "Paste":
EventBridge.emitWebEvent(JSON.stringify({ type: "paste" }));
break;
Expand Down Expand Up @@ -862,6 +870,10 @@ function loaded() {
enabledContextMenuItems.push("Rename");
enabledContextMenuItems.push("Delete");
}

if (selectedEntities.length !== 0) {
enabledContextMenuItems.push("Copy ID(s)");
}

entityListContextMenu.open(clickEvent, entityID, enabledContextMenuItems);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
//
// entityListContextMenu.js
//
// exampleContextMenus.js was originally created by David Rowe on 22 Aug 2018.
// Modified to entityListContextMenu.js by Thijs Wenker on 10 Oct 2018
// exampleContextMenus.js was originally created by David Rowe on August 22nd, 2018.
// Modified to entityListContextMenu.js by Thijs Wenker on October 10th, 2018
// Copyright 2018 High Fidelity, Inc.
// Copyright 2024 Overte e.V.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
Expand Down Expand Up @@ -137,6 +138,7 @@ EntityListContextMenu.prototype = {

this._addListItem("Cut");
this._addListItem("Copy");
this._addListItem("Copy ID(s)");
this._addListItem("Paste");
this._addListSeparator();
this._addListItem("Rename");
Expand Down
20 changes: 16 additions & 4 deletions scripts/system/create/entitySelectionTool/entitySelectionTool.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// entitySelectionTool.js
//
// Created by Brad hefta-Gaub on 10/1/14.
// Modified by Daniela Fontes * @DanielaFifo and Tiago Andrade @TagoWill on 4/7/2017
// Modified by David Back on 1/9/2018
// Created by Brad hefta-Gaub on October 1st, 2014.
// Modified by Daniela Fontes * @DanielaFifo and Tiago Andrade @TagoWill on April 7th, 2017
// Modified by David Back on January 9th, 2018
// Copyright 2014 High Fidelity, Inc.
// 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.
//
Expand Down Expand Up @@ -496,6 +496,18 @@ SelectionManager = (function() {
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() {
var entityProperties = Entities.getMultipleEntityProperties(that.selections);
var entityHostTypes = Entities.getMultipleEntityProperties(that.selections, 'entityHostType');
Expand Down
3 changes: 2 additions & 1 deletion scripts/system/html/css/edit-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,7 @@ input#property-scale-button-reset {
display: none;
position: fixed;
color: #000000;
font-family: FiraSans-SemiBold;
background-color: #afafaf;
padding: 5px 0 5px 0;
cursor: default;
Expand All @@ -1795,7 +1796,7 @@ input#property-scale-button-reset {
padding: 0 0;
}
.context-menu li.disabled {
color: #333333;
color: #777777;
}
.context-menu li.separator:hover, .context-menu li.disabled:hover {
background-color: #afafaf;
Expand Down

0 comments on commit f1475e4

Please sign in to comment.