Wednesday, November 21, 2007

ToolTipManager.scrubDelay and Hanging ToolTips in Flex

When I use validators on input controls in flex, the flex framework marks fields in error with a red border and a nice little red pop-up with a message when the mouse is moved over the component. Like this:


But sometimes, I experience that the pop-up with the error keeps hanging, even though I move the mouse out of the field in error. This led me to look for the code that performs the pop-up, and found it in ToolTipManager. This interface has three delay values that you can control:
The showDelay is simply millis from the mouse enters the field until the tooltip pop-up comes up. The hideDelay, is how long time the pop-up stays open, while the mouse is in the field. The default is 10 seconds, so if you keep the mouse over a field in error in more than 10 seconds, the pop-up will dissappear. Okay, sane enough.

Now we come to scrubDelay. From the documentation, it was a bit hard to understand (at least for me):

The amount of time, in milliseconds, that a user can take when moving the mouse between controls before Flex again waits for the duration of showDelay to display a ToolTip.

This setting is useful if the user moves quickly from one control to another; after displaying the first ToolTip, Flex will display the others immediately rather than waiting. The shorter the setting for scrubDelay, the more likely that the user must wait for an amount of time specified by showDelay in order to see the next ToolTip. A good use of this property is if you have several buttons on a toolbar, and the user will quickly scan across them to see brief descriptions of their functionality.

The first paragraph, I did not get! The second paragraph though, made me think this could be the source of my trouble. So I grabbed the source, and found out what it did. Here is my explanation:
  • When mouseOverIn or mouseOverOut handlers are called in ToolTipManagerImpl, it is checked if the mouse is over a new target component.
  • If so, the targetChangedMethod is called. This method erases any existing pop-up from another component and pop-ups a new tool-tip for the new target component.
  • BUT: If the scrubTimer is NOT running, there will be a showDelay pause. If the scrubTimer IS running, it will pop-up the new tool-tip immidiately.
I tried setting the scrubDelay larger, and it seemed to make my problem with hanging pop-ups disappear. Great, ... though I am not quite sure exactly why :-(

No comments: