Controlling a Flex tool tip’s show delay, hide delay, and scrub delay
The following example shows how you can control how long Flex will wait to display a tool tip after the user moves the mouse over a control, how long the tool tip will be visible before disappearing and how long a user can take when moving the mouse between controls before Flex waits to display a ToolTip.
Full code after the jump.
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/09/03/controlling-a-flex-tool-tips-show-delay-hide-delay-and-scrub-delay/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white" creationComplete="init()">
<mx:Script>
<![CDATA[
import mx.managers.ToolTipManager;
private function init():void {
showDelayMS = ToolTipManager.showDelay;
hideDelayMS = ToolTipManager.hideDelay;
scrubDelayMS = ToolTipManager.scrubDelay;
}
]]>
</mx:Script>
<mx:Number id="showDelayMS" />
<mx:Number id="hideDelayMS" />
<mx:Number id="scrubDelayMS" />
<mx:ApplicationControlBar dock="true">
<mx:Label text="showDelay:" />
<mx:NumericStepper id="showDelayNS"
minimum="0"
maximum="2000"
value="{showDelayMS}"
stepSize="100"
change="ToolTipManager.showDelay = showDelayNS.value" />
<mx:Spacer width="50%" />
<mx:Label text="hideDelay:" />
<mx:NumericStepper id="hideDelayNS"
minimum="0"
maximum="15000"
value="{hideDelayMS}"
stepSize="100"
change="ToolTipManager.hideDelay = hideDelayNS.value" />
<mx:Spacer width="50%" />
<mx:Label text="scrubDelay:" />
<mx:NumericStepper id="scrubDelayNS"
minimum="0"
maximum="15000"
value="{scrubDelayMS}"
stepSize="100"
change="ToolTipManager.scrubDelay = scrubDelayNS.value" />
</mx:ApplicationControlBar>
<mx:Tile>
<mx:Button label="Button 1" toolTip="Tool tip 1" />
<mx:Button label="Button 2" toolTip="Tool tip 2" />
<mx:Button label="Button 3" toolTip="Tool tip 3" />
<mx:Button label="Button 4" toolTip="Tool tip 4" />
<mx:Button label="Button 5" toolTip="Tool tip 5" />
<mx:Button label="Button 6" toolTip="Tool tip 6" />
<mx:Button label="Button 7" toolTip="Tool tip 7" />
</mx:Tile>
</mx:Application>
View source is enabled in the following example.
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.
-
Add Widgets (Content Sidebar)
This is your Content Sidebar. Edit this content that appears here in the widgets panel by adding or removing widgets in the Content Sidebar area.
9 Responses to Controlling a Flex tool tip’s show delay, hide delay, and scrub delay
Leave a Reply Cancel reply
-
Categories
- Accordion
- AccordionHeader
- ActionScript
- AddChild
- AdvancedDataGrid
- Alert
- alpha
- Animate
- AnimateProperties
- Application
- Application (Spark)
- ArrayCollection
- BarChart
- baseColor
- beta
- beta1
- beta2
- Bitmap
- Bitmap/BitmapData
- BitmapData
- BitmapFill
- BitmapFill (Spark)
- BitmapGraphic
- BitmapImage
- BitmapImage (Spark)
- BitmapImageResizeMode
- Border (Spark)
- BorderContainer (Spark)
- Box
- BuildInfo
- Button
- Button (Spark)
- ButtonBar
- ButtonBar (Spark)
- ByteArray
- Camera
- Charting
- CheckBox
- CheckBox (Spark)
- ClassFactory
- CollectionEvent
- Color
- ColorPicker
- ColorUtil
- ComboBox
- ComboBoxArrowSkin
- Compiler
- Component
- Component (Spark)
- Configuration
- Container
- ContextMenu
- ContextMenuEvent
- ContextMenuItem
- CSSCondition
- CSSSelector
- CSSStyleDeclaration
- CurrencyFormatter
- CursorManager
- Data Binding
- DataGrid
- DataGrid (Spark)
- DataGridColumn
- Date
- DateBase
- DateChooser
- DateField
- DateFormatter
- Debugging
- DefaultComplexItemRenderer
- DefaultTileListEffect
- DropDownList
- DropDownList (Spark)
- DropDownListButtonSkin
- DropDownListSkin
- DropShadowFilter
- E4X
- Effects
- Ellipse
- EmailValidator
- Embed
- Event
- Fade
- FileFilter
- FileReference
- fill
- Filters
- Flash
- Flash Integration
- FlashVars
- Flex 3 SDK
- Flex Builder
- Flex Builder 3
- Flex SDK
- Flex4
- FLVPlayback
- FocusManager
- FontLookup
- Fonts
- Form
- Form (Spark)
- FormHeading (Spark)
- FormItem
- FormItem (Spark)
- Forms
- FTETextField (Spark)
- FullScreen
- FullScreenEvent
- FxAnimateColor
- FxButtonBar
- FxCheckBox
- FXG
- FxHScrollBar
- FxHSlider
- FxList
- FxNumericStepper
- FxRadioButton
- FxRotate3D
- FxScroller
- FxTextArea
- FxTextInput
- FxToggleButton
- FxVScrollBar
- FxVSlider
- getStyleDeclaration()
- GradientEntry
- Graphic (Spark)
- HBox
- HDividedBox
- HGroup (Spark)
- HorizontalLayout
- HorizontalList
- HSBColor (Spark)
- HScrollBar (Spark)
- HSlider
- HSlider (Spark)
- HTML template
- ID3Info
- Image
- Image (Spark)
- ImageSnapshot
- itemRenderer
- JointStyle
- Label
- Label (Spark)
- Legend
- LegendItem
- LigatureLevel
- Line
- LinearGradientStroke
- LineScaleMode
- LinkBar
- LinkButton
- List
- List (Spark)
- Menu
- MenuBar
- Metadata
- MetadataEvent
- Model
- Mouse
- MouseCursor
- MouseEvent
- Move
- Namespace
- NavigatorContent (Spark)
- needsSWF
- NetConnection
- NetStream
- Nightly Builds
- NumberBaseRoundType
- NumberFormatter
- NumberValidator
- NumericCompare
- NumericStepper
- NumericStepper (Spark)
- ObjectProxy
- ObjectUtil
- paddingLeft
- paddingRight
- Panel
- Panel (Spark)
- Parallel
- Path
- PieChart
- PieSeries
- PieSeriesItem
- PopUpAnchor (Spark)
- PopUpButton
- PopUpManager
- ProgrammaticSkin
- ProgressBar
- PropertyChangeEvent
- QName
- RadialGradient
- RadioButton
- RadioButton (Spark)
- RadioButtonGroup
- RadioButtonGroup (Spark)
- Rect
- RegExp
- Regular Expressions
- Repeater
- RichEditableText
- RichText
- RichText (Spark)
- RichTextEditor
- Rotate
- Rotate3D (Spark)
- Scroller (Spark)
- Sequence
- setStyle()
- SimpleText
- SimpleText (Spark)
- skinClass
- Slider
- SliderEvent
- SolidColor
- SolidColorStroke
- Sort
- SortField
- Sound
- SoundEffect
- Spinner (Spark)
- SpriteVisualElement (Spark)
- StageDisplayState
- States
- StringUtil
- StringValidator
- StyleManager
- Styles
- SWFLoader
- SWFObject
- System
- SystemManager
- TabBar
- TabBar (Spark)
- TabNavigator
- TabStopFormat
- Text
- Text Layout Framework (TLF)
- TextArea
- TextArea (Spark)
- TextBox
- TextConverter
- TextEvent
- TextFlow
- TextFlowUtil
- TextFormat
- TextGraphic
- TextInput
- TextInput (Spark)
- TextLayoutFormat
- TextView
- Themes
- TileLayout
- TileList
- TileOrientation
- Timer
- TitleWindow
- TitleWindow (Spark)
- TLF
- ToggleButton (Spark)
- ToggleButtonBar
- ToolTip
- Transition
- Tree
- TruncationOptions
- UIComponent
- UIFTETextField
- Updater
- URLLoader
- URLRequest
- URLUtil
- URLVariables
- ValidationResultEvent
- Validator
- Validators
- VBox
- VDividedBox
- Vector
- VerticalLayout
- VerticalLayout (Spark)
- VGroup (Spark)
- Video
- VideoDisplay
- VideoElement
- VideoElement (Spark)
- VideoEvent
- VideoPlayer (Spark)
- VideoPlayerScrubBar
- ViewStack
- VScrollBar (Spark)
- VSlider
- VSlider (Spark)
- XML
- XMLList
- XMLListCollection
- ZipCodeValidator
- ZipCodeValidatorDomainType
- Zoom
-
Articles
- December 2010
- November 2010
- October 2010
- September 2010
- August 2010
- July 2010
- June 2010
- May 2010
- April 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
-
Meta


nice example. my interest is still to find a way to programatically triger tooltip without user mouse overing on a component, is it possible?
levan,
Yeah, you can use the ToolTipManager class. I think I may even have an example of that somewhere already. Check out the “Creating tool tips manually using the ToolTipManager class” entry and let me know if that was what you were looking for.
Peter
Update: Here’s a slightly simpler example. To remove the tooltip (note that you can have multiple tool tips visible at the same time using the ToolTipManager class), simply call the
ToolTipManager.destroyToolTip()method and pass in the tool tip instance to delete.<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"> <mx:Script> <![CDATA[ import mx.controls.ToolTip; import mx.managers.ToolTipManager; private var tt:ToolTip; private function create_toolTip():void { var str:String = "Tooltip text goes here..."; // We only want one tooltip. if (tt == null) { tt = ToolTipManager.createToolTip(str, 100, 50) as ToolTip; } } ]]> </mx:Script> <mx:ApplicationControlBar dock="true"> <mx:Button label="create tool tip" click="create_toolTip();" /> </mx:ApplicationControlBar> </mx:Application>Hey – Just wanted to say thanks for the helpful blog. Please keep up the great work. — doug
Hello, do you know how to disable a tooltip for a certain component?
Michael,
It may differ depending on the component, but try setting the
toolTipproperty to an empty string.Peter
Hi
great blog!
i have a question too:
How can you dispatch the show tooltip event if im using a custom tooltip?
eg im using these 2 events to contol my tooltip:
this.addEventListener(ToolTipEvent.TOOL_TIP_CREATE,createCustomTip)
this.addEventListener(ToolTipEvent.TOOL_TIP_SHOW,positionTip)
they get fired automatically if i hover the mouse over my sprite, but i want to
show the tooltip in other cases too (like if the sprite coordinates have a specified value)
This doesn’t seem to be working for hideDelay and scrubDelay. When I move my mouse off the buttons in the example above the tooltips disappear immediately regardless of what values are set for those two parameters. showDelay is working as expected though.
@David Salahi,
That sounds like the correct behavior (if I understand correctly). From ye olde docs:
via http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/managers/ToolTipManager.html#hideDelay
Peter
OK, thanks, I misunderstood what hideDelay is supposed to do. I was looking for a way to make the tooltip linger after the user moves the mouse off the associated control. I see now that what hideDelay does is hides the tooltip if the mouse remains on the control for longer than the specified delay.
I’ll have to continue searching for a way to delay the disappearance of the tooltip when the user moves the mouse off the control. My use case has a clickable link in the tooltip. However, if the user moves the mouse off the control the tooltip goes away before the user can click it.