2 Replies Latest reply on Oct 29, 2007 8:43 AM by eclesia

    DataTip positioning

    eclesia
      I have a List component that I am displaying DataTips for, but the DataTip default positioning hovers directly over the row, thus making it difficult for the user to see where they are. I would like to control the x/y position of where the DataTip is displayed, but have not found any docs that explain if/how this can be done.

      Does anyone have any suggestions/code examples of this type of control?

      Thanks
        • 1. Re: DataTip positioning
          Gregory Lafrance Level 6
          This code may help:
          <?xml version="1.0"?>
          <!-- dpcontrols/ListDataProvider.mxml -->
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" initialize="init()">
          <mx:Script>
          <![CDATA[
          import mx.events.ToolTipEvent;
          import mx.managers.ToolTipManager;
          import mx.controls.listClasses.ListItemRenderer;

          private function init():void {
          myVbox.addEventListener(ToolTipEvent.TOOL_TIP_SHOWN, positionDataTip, true);
          }

          private function positionDataTip(event:ToolTipEvent):void{
          var myRenderer:ListItemRenderer = event.target as ListItemRenderer;
          ToolTipManager.currentToolTip.x = ToolTipManager.currentToolTip.x + myRenderer.width;
          ToolTipManager.currentToolTip.y = ToolTipManager.currentToolTip.y - myRenderer.height;
          }

          ]]>
          </mx:Script>

          <mx:VBox id="myVbox" width="400" height="400">
          <mx:List id="myList" width="100" height="100" showDataTips="true">
          <mx:dataProvider>
          <mx:String>Flex Controls</mx:String>
          <mx:String>Flex Containers</mx:String>
          <mx:String>Flex Layout Options</mx:String>
          </mx:dataProvider>
          </mx:List>
          </mx:VBox>
          </mx:Application>

          • 2. Re: DataTip positioning
            eclesia Level 1
            Thanks! That worked.