Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Add a MouseListener to a GraphNode
Add a MouseListener to a GraphNode [message #1484352] Sun, 23 November 2014 10:53 Go to next message
keynne Belle is currently offline keynne BelleFriend
Messages: 30
Registered: January 2013
Member
Hello.
Is it possible to add a MouseListener to a GraphNode (org.eclipse.gef4.zest.core.widgets.GraphNode)? If so, how can I do that?
Thanks in advance.
Re: Add a MouseListener to a GraphNode [message #1484434 is a reply to message #1484352] Sun, 23 November 2014 12:30 Go to previous message
keynne Belle is currently offline keynne BelleFriend
Messages: 30
Registered: January 2013
Member
When searching through the forum, I noticed that a similar question has already been answered. So I followed the instruction given on the corresponding topic and the following code worked just fine for me:
graph.addMouseListener(new MouseListener() {

@Override
public void mouseUp(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseDown(MouseEvent e) {
// TODO Auto-generated method stub

}

@Override
public void mouseDoubleClick(MouseEvent event) {
if( graph.getSelection().get(0) instanceof GraphNode){

GraphNode selectedNode = (GraphNode) graph.getSelection().get(0);
System.out.println("The selected node is : " + selectedNode.getText());

//do something with selectedNode
}

}
});
Previous Topic:Custom Feature on Menu Bar
Next Topic: startup opening editor exception
Goto Forum:
  


Current Time: Tue Jun 19 08:25:48 GMT 2018

Powered by FUDForum. Page generated in 0.01860 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top