0

There's no problem in showing nested figures in GEF on mouse hover. On mouseHover(MouseEvent me), I add(IFigure), and on mouseExited(MouseEvent me) I remove the figure.

But as soon as I add a Button(Draw2d), or I add a figure which has a MouseListener() attached to it, now when I hover over the newly added figure(inside the parent), it disappears.

I figured the problem is that the first figure calls its mouseExited(MouseEvent me) method.

So, I did this in the parent figure's mouseExited(MouseEvent me):

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

I see on mouse exit, if it still is in the bounds of the parent figure, it doesn't remove the child figure.

But this works most of the time. Sometimes my mouse is out of the parent figure completely, yet the child figure isn't removed from the parent figure. I have no idea what is happening.

Is this a bug? Or is there a better way to do this?

nullpointer
  • 490
  • 2
  • 4
  • 20

1 Answers1

0

I would suggest to try using a different strategy in hiding/showing figures:

  1. On parent creation always add the child and mark it as not visible, child.setVisible(false)
  2. Replace all add() and remove() invocation respectively with setVisible(false) and setVisible(true)
e.persiani
  • 176
  • 1
  • 3