【问题标题】:Flex - prevent tooltips from hiding. Persistent tooltipsFlex - 防止工具提示隐藏。持久性工具提示
【发布时间】:2011-04-27 05:46:55
【问题描述】:

我正在尝试防止自定义工具提示消失。我已经尝试了三个运行,从通常的嫌疑人那里借用: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>

【问题讨论】:

  • 您是否尝试过 Monkey 修补 ToolTipManager.destoryToolTip 方法以防止其被破坏?

标签: apache-flex actionscript-3 panel tooltip


【解决方案1】:

使用一些 JavaScript 在链接的 onmouseover 部分显示工具提示:

<a href="page.aspx" onmouseover=showtooltip("Tooltip Text")></a>

请勿在您的链接中包含任何 JavaScript 例程,例如 onmouseout=hidetooltip(),它将保持打开状态。

P.S.:您可以在包含onmouseout=hidetooltip() 的“工具提示文本”中放置一个链接,例如:

<a href=originalpage.aspx onclick=hidetooltip()>Close</a>

【讨论】:

  • showtooltip 和 hidetooltip 类型的 javascript 有很多来源,只需 google 即可。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-21
  • 1970-01-01
相关资源
最近更新 更多