Double click on white space [message #498749] |
Wed, 18 November 2009 09:25  |
Eclipse User |
|
|
|
Originally posted by: c.krause.cwi.nl
Hi,
the existing posts about capturing double-click events didn't work in my
application. I tried to capture REQ_OPEN at the diagram editpart but
that didn't work. Then I tried to add a mouse listener to the diagram
figure like this:
protected IFigure createFigure() {
// Create free form layer:
Figure layer = new FreeformLayer();
layer.setBorder(new MarginBorder(3));
layer.setLayoutManager(new FreeformLayout());
layer.addMouseListener(new MouseListener() {
public void mouseDoubleClicked(MouseEvent me) {
System.out.println("double click: " + me);
}
// ...
});
// Create the static router for the connection layer
ConnectionLayer connections = (ConnectionLayer)
getLayer(LayerConstants.CONNECTION_LAYER);
connections.setConnectionRouter(new ShortestPathConnectionRouter(layer));
return layer;
}
But I still get no events. I do get events if I listen to the
FigureConvas of the graphical viewer but then I get ALL double clicks,
and not just the ones in the white space.
ciao,
Christian
|
|
|
Re: Double click on white space [message #500187 is a reply to message #498749] |
Wed, 25 November 2009 04:57  |
Eclipse User |
|
|
|
Hi, I am using a Tool to capture double-clicks on the EditParts, and also on the whitespace that represents the RootEditPart. I don't know if that's already on your list of methods that don't work, but it works fine for me.
Regards,
Gerrit
public class MyTool extends PanningSelectionTool {
// ...
@Override
protected boolean handleDoubleClick(int button) {
EditPart editPart = getCurrentViewer().findObjectAtExcluding(
getLocation(),
getExclusionSet(),
getTargetingConditional());
if(editPart instanceof ScalableFreeformRootEditPart) {
// It's the RootEditPart, which usually has a ViewPort with Layers as its Figure.
// This means the whitespace has received a double-click,
// unless the setup is vastly different.
}
else {
// Some other EditPart's Figure has been double-clicked on.
}
return super.handleDoubleClick(button);
}
}
|
|
|
Powered by
FUDForum. Page generated in 0.27674 seconds