I use the Java version, JGraphX.

I simply want the cell to stay where it was, when the drop target is invalid, no matter where I released the mouse.

I have overwritten isValidDropTarget() and I want to cancel the cell movement if it returns false.

At the moment, a mxStackLayoutManager executes vertical layout on target swimlane.

When I move a cell to a invalid drop target, the cell is not moved right there, but its order in the swimlane has changed regarding the Y-coordinate of the drop location. I dont't want this behaviour.

After I looked through moveCells(), cellsMoved(), cellsAdded(), getDropTarget() I finally know that the place to change this behaviour is mxGraphHandler (I think). But where exactly can I change this? I have not understand the mouseReleased() and the drop() method yet, but is it possible that anyone can give me some advice where to change it?

(Again, I simply want the cell to stay where it was, when the drop target is invalid, no matter where I released the mouse.)

Thank you in advance!

asked 27 Oct '12, 20:04

fachexot's gravatar image

fachexot
461210
accept rate: 11%


Check if hitting the "ESC" key solves your problem. If it does, then search the JGraphX code for the KeyEvent.VK_ESCAPE constant and there you get how you can cancel it.

link

answered 28 Oct '12, 02:23

Lofi's gravatar image

Lofi
1.0k1221
accept rate: 37%

Thanks Lofi, so far.

While pressing the mouse button (during the movement) the "ESC" key does what I need.

2 Problems:

  1. I want this to happen AFTER mouse button released, and the drop target was not valid. (So I need the correct position where to put a potential movement canceling)

  2. The KeyEvent.VK_ESCAPE event pointed to some method in mxCellEditor. This class' description says: "To control this editor, use mxGraph.invokesStopCellEditing, mxGraph.enterStopsCellEditing and mxGraph.escapeEnabled." But that does not work, there are neither such functions nor a reference to a mxCellEditor.

Can you please help me getting this work? Thanks in advance, Fachexot

(28 Oct '12, 08:03) fachexot
1

From the looks of it mxGraphHandler seems the proper place. It has a method installDragGestureHandler() and there's a method dragDropEnd. I put a breakpoint there. In debug mode it also jumps there when you hit the ESC key. So I guess you can ignore my initial suggestion with VK_ESCAPE. And then there's mxGraphTransferHandler.java with an exportDone method. You might want to check that out.

(28 Oct '12, 11:49) Lofi

Thanks. Gonna try it tomorrow.

(28 Oct '12, 18:01) 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:

×194
×37
×13

Asked: 27 Oct '12, 20:04

Seen: 2,703 times

Last updated: 28 Oct '12, 18:01