views:

30

answers:

0

Hi Folks, I'm trying to prevent a custom tooltip from disappearing. I've tried three runs at this, borrowing from the usual suspects: Peter Dehann, MonkeyPatch and others. As you can see from the code below I'd like to stay within the tool tip paradigm and not go to popups.

Can anyone suggest a way to persist a tooltip? The intent here is to have a component which can be cut and paste from.

Thanks, Doug

<?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>