利用ToolTipManager类检测并取得Flex应用中当前ToolTip状态/内容的例子
By Minidxer | April 6, 2008
在Flex中如何利用ToolTipManager类设定toolTip显示时间/停留时间的例子中我们了解如何通过设置ToolTipManager.hideDelay属性,来设置ToolTip显示有效时间。接下来的例子演示了如何通过指定ToolTipManager.currentToolTip属性和toolTipShown时间,取得Flex应用中当前显示Tool tip内容。
让我们先来看一下Demo(可以右键View Source或点击这里察看源代码):
下面是完整代码(或点击这里察看):
Download: main.mxml
- <?xml version="1.0" encoding="utf-8"?>
- <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
- layout="vertical"
- verticalAlign="middle"
- backgroundColor="white">
- <mx:Script>
- <![CDATA[
- import mx.controls.Alert;
- import mx.controls.ToolTip;
- import mx.events.ToolTipEvent;
- import mx.managers.ToolTipManager;
- private function button_toolTipShown(evt:ToolTipEvent):void {
- var toolTip:ToolTip = ToolTipManager.currentToolTip as ToolTip;
- Alert.show(evt.toString(), toolTip.text);
- }
- ]]>
- </mx:Script>
- <mx:ApplicationControlBar dock="true">
- <mx:Button id="button"
- label="Roll over button to display tool tip"
- toolTip="The quick brown fox jumped over the lazy dog"
- toolTipShown="button_toolTipShown(event);" />
- </mx:ApplicationControlBar>
- </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer
Topics:
Flex |
Tags: currentToolTip, Flex, toolTip, ToolTipManager, toolTipShown