Goal: I have a Dojo tree and I want each of the elements to be a mxDragSource, with a separate 'funct'-function (the function creating the cell in the graph).

Situation: First method I used was to make a mxDragSource of the tree-element I had a mosueDown event on. I like doing it this way because this way only the elements I'm actually using become a mxDragSource. The problem with this is that the first time I have a mousedown event, the node is not yet a mxDragSource and so it cannot be dragged yet. Only after I have dragged it ones (and it has become a mxDragSource), it can be DnD'ed on the graph.

My second approach was to make all elements of the tree a mxDragSource (using a loop) right after the tree is created. This solves the extra drag action, but now I have another problem: all cells that get created are the same; it doesn't matter which element I DnD eventhough these elements are different.
I'll try to explain this better: all tree elements have their own information. I add this information in the 'funct'-function that I add to the mxDragSource. However, for some reason the cell that gets created always has the information of the last mxDragSource created.
The only reason I can think of why this happens, is that the 'funct'-function is not evaluated untill all mxDragSources have been created. At this point it contains the information of the last element that was looped.

My questions: 1. Is it possible to make the tree-element a mxDragSource AND make drag it immediately afterwards; so during the same mouseDown-event? 2. Can anybody tell me how to create multiple mxDragSources at once?

asked 06 Feb '13, 08:06

Noodles's gravatar image

Noodles
11
accept rate: 0%


Solved it by simulating a mousedown-event on the same node after making it draggable. I used the code from: http://stackoverflow.com/questions/6157929/how-to-simulate-mouse-click-using-javascript/6158050#6158050

link

answered 19 Mar '13, 08:29

Noodles's gravatar image

Noodles
11
accept rate: 0%

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:

×228
×37
×29
×6

Asked: 06 Feb '13, 08:06

Seen: 1,227 times

Last updated: 19 Mar '13, 08:29