Skip to content

Commit ccd4c7f

Browse files
#641 Support Right-clicking to copy IdentifierTool values (#642)
1 parent a237c0d commit ccd4c7f

File tree

3 files changed

+439
-394
lines changed

3 files changed

+439
-394
lines changed

src/essence/Ancillary/ContextMenu.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ function showContextMenuMap(e) {
4747
"</div>",
4848
"<ul>",
4949
"<li id='contextMenuMapCopyCoords'>Copy Coordinates</li>",
50+
Object.keys(L_._toolCopyables).map((key, idx) => {
51+
const c = L_._toolCopyables[key]
52+
const items = []
53+
if( c.title && c.copyable)
54+
items.push(`<li id='contextMenuCopyable' key='${key}'>${c.title}</li>`)
55+
return items.join('\n')
56+
}).join('\n'),
5057
contextMenuActions.map((a, idx) => {
5158
const items = []
5259
if(a.for == null) {
@@ -89,13 +96,26 @@ function showContextMenuMap(e) {
8996
})
9097

9198
$('#contextMenuMapCopyCoords').on('click', function () {
92-
F_.copyToClipboard(JSON.stringify(Coordinates.getAllCoordinates()))
99+
F_.copyToClipboard(
100+
JSON.stringify(Coordinates.getAllCoordinates(), null, 2)
101+
)
93102
$('#contextMenuMapCopyCoords').text('Copied!')
94103
setTimeout(function () {
95104
$('#contextMenuMapCopyCoords').text('Copy Coordinates')
96105
}, 2000)
97106
})
98107

108+
$('#contextMenuCopyable').on('click', function () {
109+
const that = this
110+
const key = $(that).attr('key')
111+
const copyable = L_._toolCopyables[key]
112+
F_.copyToClipboard(JSON.stringify(copyable.copyable, null, 2))
113+
$(that).text('Copied!')
114+
setTimeout(function () {
115+
$(that).text(copyable.title)
116+
}, 2000)
117+
})
118+
99119
contextMenuActionsFull.forEach((c) => {
100120
$(`#contextMenuAction_${c.idx}_${c.idx2}`).on('click', function () {
101121
const a = c.contextMenuAction

src/essence/Basics/Layers_/Layers_.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const L_ = {
2323
UserInterface_: null,
2424
TimeControl_: null,
2525
tools: null,
26+
_toolCopyables: {},
2627
//The full, unchanged data
2728
configData: null,
2829
layers: {

0 commit comments

Comments
 (0)