Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Double click on white space
Double click on white space [message #498749] Wed, 18 November 2009 14:25 Go to next message
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 09:57 Go to previous message
Gerrit  is currently offline Gerrit
Messages: 30
Registered: July 2009
Member
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);
	}
}
Previous Topic:Custom SWT widgets in palette
Next Topic:isDirty called to late
Goto Forum:
  


Current Time: Fri Sep 19 11:50:44 GMT 2014

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

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