【问题标题】:Showing nested figures in GEF on mouse hover在鼠标悬停时在 GEF 中显示嵌套图形
【发布时间】:2014-04-14 08:18:15
【问题描述】:

鼠标悬停时在 GEF 中显示嵌套图形没有问题。在mouseHover(MouseEvent me),我在add(IFigure),在mouseExited(MouseEvent me),我删除了这个数字。

但只要我添加了一个Button(Draw2d),或者我添加了一个附有MouseListener() 的图形,现在当我将鼠标悬停在新添加的图形上(在父图形内)时,它就会消失。

我认为问题在于第一个数字调用了它的mouseExited(MouseEvent me) 方法。

所以,我在父图的mouseExited(MouseEvent me)

Point exitLocation = me.getLocation();
if (containsPoint(exitLocation.x, exitLocation.y) == false) {
   remove(childFigure);
}

我在鼠标退出时看到,如果它仍然在父图形的范围内,它不会删除子图形。

但这在大多数情况下都有效。有时我的鼠标完全不在父图形之外,但子图形并没有从父图形中删除。我不知道发生了什么。

这是一个错误吗?或者有更好的方法吗?

【问题讨论】:

    标签: eclipse-gef draw2d


    【解决方案1】:

    我建议尝试使用不同的策略来隐藏/显示数字:

    1. 在创建父级时始终添加子级并将其标记为不可见,child.setVisible(false)
    2. 将所有add()remove() 调用分别替换为setVisible(false)setVisible(true)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-09
      • 2017-11-21
      • 2017-03-06
      • 1970-01-01
      相关资源
      最近更新 更多