我正在尝试阻止自定义工具提示消失。我已经尝试了三次尝试,借用了常见的嫌疑人:Peter Dehann,MonkeyPatch和其他人。正如您从下面的代码中可以看到的,我希望保持在工具提示范例内而不是弹出窗口。
有人可以提出一种方法来坚持工具提示吗?这里的目的是拥有一个可以剪切和粘贴的组件。
谢谢, 道格
<?xml version="1.0" encoding="utf-8"?>
<s:Application minHeight="600" creationComplete="application1_creationCompleteHandler(event)"
minWidth="955"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
import mx.events.ToolTipEvent;
protected function button1_clickHandler(event:MouseEvent):void {
// TODO Auto-generated method stub
}
protected function button1_toolTipCreateHandler(event:ToolTipEvent):void {
createCustomToolTip("title", "", event);
}
// TODO Auto-generated method stub
private function createCustomToolTip(title:String, body:String, event:ToolTipEvent):void {
var ptt:CustomToolTip = new CustomToolTip();
ptt.title = title;
ptt.bodyText = (event.currentTarget as Button).toolTip;
event.toolTip = ptt;
}
protected function button1_toolTipHideHandler(event:ToolTipEvent):void
{
// TODO Auto-generated method stub
event.stopPropagation();
event.preventDefault();
event.stopImmediatePropagation();
}
import mx.managers.ToolTipManager;
private var tt:CustomToolTip;
private var cc:CustomToolTip;
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 CustomToolTip;
}
}
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
mx.managers.ToolTipManager.toolTipClass = CustomToolTip;
//mx.managers.ToolTipManager.scrubDelay = 100000;
//mx.managers.ToolTipManager.hideDelay = 1000000;
}
protected function button1_toolTipEndHandler(event:ToolTipEvent):void
{
event.preventDefault();
event.stopImmediatePropagation();
// TODO Auto-generated method stub
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:VBox>
<mx:Button click="button1_clickHandler(event)"
toolTip="helloWorld" toolTipHide="button1_toolTipHideHandler(event)" toolTipEnd="button1_toolTipEndHandler(event)"
toolTipCreate="button1_toolTipCreateHandler(event)" >
</mx:Button>
<mx:Button label="create tool tip" click="create_toolTip();" />
<mx:Button toolTip="hello world" label="hello">
</mx:Button>
</mx:VBox>
</s:Application>
答案 0 :(得分:0)
使用一些JavaScript来显示链接的onmouseover
部分中的工具提示:
<a href="page.aspx" onmouseover=showtooltip("Tooltip Text")></a>
在您的链接中不包含onmouseout=hidetooltip()
之类的任何JavaScript例程,它将保持打开状态。
P.S。:您可以在包含onmouseout=hidetooltip()
的“工具提示文字”中添加一个链接,例如:
<a href=originalpage.aspx onclick=hidetooltip()>Close</a>