How to add a double-click listener to my GEF editor?

倾然丶 夕夏残阳落幕 提交于 2019-12-01 03:45:39
vainolo

In the GraphicalEditPart of the "box" for which you want to add the listener, you have to override the performRequest(Request req) method. When the framework identifies a double-click on the part's figure, it calls this method with a request that has req.getType()==RequestConstants.REQ_OPEN. You can take over from here. Complete code to test that his works:

@Override
public void performRequest(Request req) {
    if(req.getType() == RequestConstants.REQ_OPEN) {
        System.out.println("requested double-click."); 
    }
}

Hope this does the trick.

viewer.getControl().addListener(SWT.MouseDoubleClick, new Listener() {

        @Override
        public void handleEvent(Event event) {
        //write the double click action
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!