Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Prevent Keyboard copy/paste of nodes

$
0
0

@jothibaskaran wrote:

Hi,

I want to disable the copy and paste of my GoJS node using the keyboard shortcuts Ctrl+C and Ctrl+V. But i need this function to happen on click of a button in my context menu.

this.diagram.allowCopy = true; allows duplication with both keyboard and button click .
this.diagram.allowCopy = false; prevents both.

this is my function to duplicate the node via context menu click:

('ContextMenuButton', { 'ButtonBorder.fill': 'white', '_buttonFillOver': 'lightgray' }, (go.TextBlock, ‘Duplicate’,
{ margin: 12 }
),
{ click: (e, pt, compInstance) => this.duplicateComponent(compInstance, pt, e) })

duplicateComponent(compInstance, pt, e) {
this.diagram.commandHandler.copySelection();
const point = new go.Point(e[‘Ir’][‘offsetX’] + 20, e[‘Ir’][‘offsetY’] + 20);
this.diagram.commandHandler.pasteSelection(point);
this.propertiesFlagEvent.emit(’’);
this.startAutoSave();
}

How can i prevent just the keyboard shortcuts?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles