1 Reply Latest reply on Feb 7, 2008 10:37 AM by Brandon Ellis

    Display tooltip on focus

    JoshBeall Level 1
      Hi All,

      I have a textbox for entering a date, and the ToolTip is "MM/DD/YYYY", so people can see what format date is required.

      However, if they are simply tabbing through the form (as many people do), they will never see the tooltip. They have to actually position the mouse over the TextInput to see the tooltip.

      Is there a way to display the tooltip on focus? So that as soon as they tab to the date textinput, it pops up the tooltip. I thought about listening for the focus event, and then programmatically popping up a tooltip -- but I couldn't figure out a way to programmatically pop up the tooltip. The only way seemed to be if the mouse was hovering over the textinput.

      Suggestions?

      -Josh
        • 1. Re: Display tooltip on focus
          Brandon Ellis
          Hi,
          Here's how you could do it.
          quote:


          <mx:Script>
          <![CDATA[
          import mx.core.IToolTip;
          import mx.managers.ToolTipManager;

          private var currToolTip:IToolTip
          private function showTT(sender:Object):void {
          currToolTip = ToolTipManager.createToolTip(sender.toolTip, (sender.x + sender.width) + 10, (sender.y - 5));
          }

          private function hideTT():void {
          ToolTipManager.destroyToolTip(currToolTip);
          }

          ]]>
          </mx:Script>
          <mx:TextInput id="fname" x="96" y="47" toolTip="Enter your first name" focusIn="showTT(fname)" focusOut="hideTT();"/>
          <mx:TextInput id="lname" x="96" y="118" toolTip="Enter your last name" focusIn="showTT(lname)" focusOut="hideTT();"/>
          <mx:Text x="96" y="31" text="FirstName:"/>
          <mx:Text x="96" y="101" text="LastName:"/>



          Hope that helps