ScrollingGraphicalViewer选择和取消选择监听器

时间:2012-10-01 14:49:17

标签: eclipse-gef

我需要在GEF图表中选择数字时触发方法。 当我选择一个数字时,addSelectionChangedListener运行良好,但如果我再次点击同一个数字(“取消选择”),则不会触发监听器。

我该如何解决?

final GraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
     public void selectionChanged(SelectionChangedEvent event) {
    //Fired when figure is selected, but not when same figure is selected again

     }
});

1 个答案:

答案 0 :(得分:0)

我认为你不能通过选择机制为GEF数字实现切换行为。当选择更改时会触发selectionChanged事件,因此在同一个数字上单击两次将无法实现。

考虑到在选择另一个图形时取消选择图形并且可以从传入的SelectionChangedEvent对象中检索该元素,可能需要采用不同的方法。

此外,您应该只关心用户在图表中选择图形而不是与任何其他工作台部件不同的元素。

相关问题