Is it possible to allow a user to create an edge between two cells by left clicking on the source cell's handle and then clicking on the target cell's handle. This should also appear like the current drag operation, where the edge is following the mouse pointer until another click happends.

asked 16 May '12, 07:50

cwsunderland's gravatar image

cwsunderland
113
accept rate: 0%


I think I figured it out by extenging the mxConnectionHandler class and overriding mousePressed and mouseReleased methods.

@Override
public void mousePressed(MouseEvent e) {
    if (this.isActive()) {
        super.mouseReleased(e);
    } else {
        super.mousePressed(e);
    }
}

@Override
public void mouseReleased(MouseEvent e) {

}
link

answered 16 May '12, 08:16

cwsunderland's gravatar image

cwsunderland
113
accept rate: 0%

How would you do this in javascript?

I'm trying to work out the same behavior you described, where, when you click a valid vertex (some may be invalid), a new edge is created with the chosen vertex as source, and keeps following the mouse until a valid destination vertex is clicked.

Eg, I have two "output" nodes and three "input" nodes. To start with, clicking an input node should do nothing. Clicking an output node creates a new edge. At this point, clicking an input node links the two nodes, but clicking anywhere else cancels the linking (removes the edge), and the user has to start over by clicking an output node.

Any pointers / hints appreciated!

Thanks.

link

answered 04 Nov '12, 23:43

Freakvent's gravatar image

Freakvent
1
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:

×194
×100
×37

Asked: 16 May '12, 07:50

Seen: 1,561 times

Last updated: 04 Nov '12, 23:43