Ever wonder how to control the amount of time that a tool tip stays visible before disappearing? Well, wonder no more! You can control the length of time that a tool tip remains visible from the default 10 seconds to whatever you want by setting the ToolTipManager.hideDelay property. Simply set the value to however many milliseconds you want the tool tip to be visible for before disappearing and you’re set.

Full code after the jump.

The following example shows how to set the hide delay for a tool tip to 2 seconds (down from the default 10 seconds, or 10000 milliseconds), by setting the ToolTipManager.hideDelay property:

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/07/23/setting-the-amount-of-time-that-a-tool-tip-is-visible-using-the-tooltipmanager-class/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Script>
        <![CDATA[
            import mx.managers.ToolTipManager;

            // milliseconds (default 10000)
            ToolTipManager.hideDelay = 2500;
        ]]>
    </mx:Script>

    <mx:ApplicationControlBar dock="true">
        <mx:Label text="Mouse over the Button below to see the tool tip." />
    </mx:ApplicationControlBar>

    <mx:Button id="button" label="click me"
            toolTip="I'm a fabulous tool tip." />

    <mx:Label text="The tool tip will disappear after {(ToolTipManager.hideDelay/1000).toFixed(1)} seconds." />

</mx:Application>

View source is enabled in the following example.

 
Tagged with:
 
About The Author

Peter deHaan

Peter deHaan currently works for Adobe on the Flex SDK QA team. While not working on Flex, Flash, and ColdFusion applications, Peter enjoys making up bios and writing in 3rd person. Peter's rarely updated blog can be found at blogs.adobe.com/pdehaan/, actionscriptexamples.com, airexamples.com, and coldfusionexamples.com.

2 Responses to Setting the amount of time that a tool tip is visible using the ToolTipManager class

  1. David Salahi says:

    As with your other post on this topic (http://blog.flexexamples.com/2007/09/03/controlling-a-flex-tool-tips-show-delay-hide-delay-and-scrub-delay/), the delay doesn’t seem to be working here either. The tooltip disappears immediately after I move the mouse off the “click me” button above.

    Could this be a bug in the current version of Flash Player? In the right column above it shows that I’m running WIN 10,1,82,76 (debug).

    • Peter deHaan says:

      @David Salahi,

      From the docs for ToolTipManager.hideDelay:

      The amount of time, in milliseconds, that Flex waits to hide the ToolTip after it appears. Once Flex hides a ToolTip, the user must move the mouse off the component and then back onto it to see the ToolTip again. If you set hideDelay to Infinity, Flex does not hide the ToolTip until the user triggers an event, such as moving the mouse off of the component.

      Based on the red text above I don’t believe this is a bug.

      Peter

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Anti-Spam Protection by WP-SpamFree