Hi,

The mxClipboard.paste function always pastes to the same location relative to the copied cells, I would like to paste where the user right clicks on the graph.

Is there a away to achieve this?

Thanks.

asked 17 Jul '12, 05:45

LeeBlueBay's gravatar image

LeeBlueBay
23
accept rate: 0%


Here is a JavaScript version (where evt is the native mouse event):

var cells = graph.getImportableCells(mxClipboard.cells);

var pt = mxUtils.convertPoint(graph.container,
    mxEvent.getClientX(evt), mxEvent.getClientY(evt));
var bounds = graph.getBoundingBoxFromGeometry(cells);
var dx = pt.x - bounds.x;
var dy = pt.y - bounds.y;

var parent = graph.getDefaultParent();
cells = graph.importCells(cells, dx, dy, parent);
graph.setSelectionCells(cells);
link

answered 17 Jul '12, 08:15

Gaudenz's gravatar image

Gaudenz
80.1k1310
accept rate: 39%

Thanks Gaudenz, works a treat.

(17 Jul '12, 09:10) LeeBlueBay

From mxGraphTransferHandler.java I see that in your case you have to call the setLocation method with the right click coordinates as parameter before you invoke the paste operation.

link

answered 17 Jul '12, 07:44

Lofi's gravatar image

Lofi
1.0k1221
accept rate: 37%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×39

Asked: 17 Jul '12, 05:45

Seen: 959 times

Last updated: 17 Jul '12, 09:10