Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Copy and Paste - Node (Read 3717 times)
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Copy and Paste - Node
Jun 7th, 2018 at 9:52pm
Print Post  
Hi Lyubo,

how does copying and pasting elements?

Tutorial4(Tutorial 4: Custom Nodes Integration) is not working Sad


Regards,
Kuzya
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Copy and Paste - Node
Reply #1 - Jun 11th, 2018 at 5:25am
Print Post  
Hi,

Tutorial4 is working as expected in my test. Which browser are you using? Are there any errors shown in the browser's console window?

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Re: Copy and Paste - Node
Reply #2 - Jun 11th, 2018 at 7:48am
Print Post  
Hi Lyubo,

browser - Firefox
Errors - Tutorial4.html:15 Uncaught TypeError: diagram.copyToClipboard is not a function
    at HTMLButtonElement.onclick (Tutorial4.html:15)

Regards,
Kuzya
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Copy and Paste - Node
Reply #3 - Jun 11th, 2018 at 8:04am
Print Post  
Can you verify that the diagram is actually loaded and interactive? Can you draw nodes/links on the canvas, and does the NodeListView display nodes?

In the case of this sample, ''diagram'' is a variable for easy access to the diagram control, but also the name of the canvas html element. You can try accessing the diagram object like this:

Code (Javascript)
Select All
var d = MindFusion.Diagramming.Diagram.find("diagram"); // diagram is the id of the canvas html element.
if (d == null)
    alert('diagram is not loaded');
else
    d.copyToClipboard(); // should copy the selection to clipboard.  



Does the above work in your case?

Lyubo
  
Back to top
 
IP Logged
 
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Re: Copy and Paste - Node
Reply #4 - Jun 15th, 2018 at 11:37am
Print Post  

Hi Lyubo,

I need to copy selected elements and edges.

Regards,
Kuzya
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Copy and Paste - Node
Reply #5 - Jun 18th, 2018 at 5:28am
Print Post  
Hi,

The copyToClipboard method copies all selected items to the clipboard. You can add items to the selection by using DiagramItem.setSelected(true), or via the Diagram.getSelection() property.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Re: Copy and Paste - Node
Reply #6 - Aug 6th, 2018 at 8:33am
Print Post  
Hi,

we try to copy an element from one diagram to another tab.
Apparently this is not possible via the system clipboard.
Is there a workaround for this?


Regards,
Kuzya
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Copy and Paste - Node
Reply #7 - Aug 6th, 2018 at 10:52am
Print Post  
Hi,

With the sytemClipboard argument enabled, the control will assign the data to window.clipboardData object. That used to work between tabs at some point, but now seems disabled - probably because of security concerns. If you set the argument to false, copied data is saved as json in window.mf_clipboard field - you could try saving its value in browser's local storage to access from other tabs, and read from local storage just before calling paste.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Re: Copy and Paste - Node
Reply #8 - Aug 7th, 2018 at 6:23am
Print Post  
Hi,

Thanks for the answer, this works great.  Smiley
But I have another problem: I would like to paste the copied element at the cursor position. Is that possible?

Apparently, the position to be specified always depends on the original element.


Regards,
Kuzya
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Copy and Paste - Node
Reply #9 - Aug 7th, 2018 at 8:58am
Print Post  
Hi,

The only control you have over position is via the offset arguments of pasteFromClipboard method, where offsets are relative to original items' positions. You could save x/y coordinates of diagram.selection.bounds in your local-storage clipboard as well, and then specify offsetX/Y as the difference between wanted position and saved selection position when pasting -

d.pasteFromClipboard(cursorX - savedX, cursorY - savedY);

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint