开发者

Ignore mouse focus on tool-tip?

I've created something that works like a ToolTip in my Flex application. When I roll over a certain item renderer, I pop up a new control, position it, and remove it on roll out. The order of operations is like this:

  1. Roll over event handler triggered.
  2. Add the tooltip to this.systemManager.topLevelSystemManager.toolTipChildren.
  3. On creation complete of my tooltip, set x, set y coordinates of the tooltip (on creation complete so the width and height are calculated since th开发者_高级运维ey are dynamic).
  4. Roll out event handler triggered.
  5. Remove tooltip.

This worked fine when I set the x and y coordinates to be x+10, y+10 from the current mouse position. I wanted to add something that re-positioned the tool-tip if it was going to be drawn partially off screen. I added a step that would calculate if it would be drawn off screen, and re-position the tooltip if it was going to be cut off.

The problem with my solution seems to be that it now runs in an infinite loop of redraws, since adding the tool-tip to the screen underneath the mouse triggers the "rollOut" on the item renderer. This triggers the removal of the tooltip, and starts the process over again from 1.

So I guess my question is: is there any way to ignore tooltip so it doesn't take the mouse focus away from the item renderer that is now under it? Or are there any other good solutions? Thanks in advance.


One way is to ensure that the drawn tool-tip also does not come under the mouse.

Or you can add a short delay before the tool-tip actually fades after the rollOut. Then you can disable fading if the mouse_over of the new tool-tip is fired.

This way the tool-tip will only fade if the mouse leaves BOTH the DisplayObject that triggers the tool-tip AND the tool-tip.


Probably should have searched a bit more before posting this question. For anyone else looking, I just needed to set mouseEnabled=false and mouseChildren=false options on my tooltip.


I'd check the currentTarget and target properties of your events, to know who dispatched it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜