Hi folks!

\n

I'm currently trying hard to get the parent cell of the drag source when doing a drag & drop operation. As I'm listening to the mxEvent.MOVE_CELLS event, I get all the properties (like target, moved cells, etc), but I see no way to retrieve the source cell(s)?!\nI tried to work around that, using the CHANGE event and save the old parent object before moving around. But as the vertex stays selected all the time, I cant't recognize the parent anymore, if I drag the vertex directly to another container. (eg. A --> B --> C)

asked 30 May '11, 03:38

gman's gravatar image

gman
2318
accept rate: 0%


ok, i solved it by using an array to cache the source element.

link

answered 30 May '11, 23:50

gman's gravatar image

gman
2318
accept rate: 0%

How do you manage Drag and Drop events in JGraph? I couldn't find a good an simple example of doing that!

link

answered 17 Jul '11, 15:43

eferrante's gravatar image

eferrante
2116
accept rate: 0%

How do you manage Drag and Drop events in JGraph? I couldn't find a good an simple example of doing that!

  • Add listener to mxGraph that listens to mxEvent.CELLS_MOVED (starts and finishes within moveCells()) or mxEvent.MOVE_CELLS (starts before cellsMoved() and finishes later than that)
  • Add listener to mxGraphModel that listens to mxEvent.CHANGE (or mxEvent.EXECUTE for atomic changes) and looks out for mxGeometryChange changes, that have a change in x / y data

  • Add listener to mxGraphModel that listens to mxEvent.CHANGE (or mxEvent.EXECUTE) and looks out for mxChildChange changes.

You can get the source cell with getPrevious() and the target with getParent():

[...]
if (change instanceof mxChildChange)
{
    mxChildChange childChange = (mxChildChange) change
    mxCell previousParent = (mxCell) childChange.getPrevious();
}

but I see no way to retrieve the source cell(s)?!

Just try getParent() on of the elements returned by getProperty("cells") to get its source parent.

link

answered 27 Oct '12, 12:01

fachexot's gravatar image

fachexot
461210
accept rate: 11%

edited 27 Oct '12, 12:13

So, if i need to detect the Drag ang Drop event, How can i use mxEvent.CHANGE in order to know what object have i dropped?

Thanks a lot.

(30 Oct '12, 12:42) walolinux

mxChildChange.getChild()

(30 Oct '12, 13:45) fachexot
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:

×37
×1

Asked: 30 May '11, 03:38

Seen: 8,070 times

Last updated: 30 Oct '12, 13:45