Different positioning for different tooltips using ToolTip Manager Class.

my previous post tells the basic usage of the ToolTip Manager Class , here i am with an example where in you can give different positioning for different tooltips.This means if i have two controls and for the first control i want the tooltip on right and for the second control i want the tooltip on bottom of the control, so this can be achived using the ToolTip Manager class and iam going to tell you how that can be achived.

Here we got to use the method called createToolTip(), which takes the parameters.

syntax ::

createToolTip(text:String, x:Number, y:Number, errorTipBorderStyle:String,
context:IUIComponent):IToolTip

Here we will be usign the text,x,y parameters specifications only for our positioning.

First create an instance to the ToolTip Class and call the createToolTip method of the ToolTip Manager and asing the return value to the ToolTip Class instance.Like below.

private var tip:ToolTip;

tip = ToolTipManager.createToolTip(‘Right side tooltip’,
event.currentTarget.x + event.currentTarget.width + 10,
event.currentTarget.y)
as ToolTip;

Call these staments on an event of the control for exmaple on mouseOver and we got to destroy the ToolTip instance after the usage like on mouseOut.So that the instance can be used for other control in the Application.

And to destroy the ToolTip instance use the method destroyToolTip(tip) of the ToolTip Manager Class.

Similarly we can write code for any positioning of the tooltip for any control.

Click here to view the Example.

Enjoy the post and tune on to see the source code for this Exmaple.

Advertisements

2 Responses to Different positioning for different tooltips using ToolTip Manager Class.

  1. Sandesh says:

    Help me in destroying the tooltip of flex. This is the code i m trying to use. But the tooltip appears right when oldpass is less than 6 chars but does not disappears after entering 7 chars.

    // Remove the tooltip
    private function killToolTip():void
    if(myToolTip!=null){
    //Alert.show(“myToolTip in if”+myToolTip);
    ToolTipManager.destroyToolTip(myToolTip);
    myToolTip=null;
    }
    }

    if((oldpass.length>0)&&(oldpass.length<6)){
    ……
    ……
    }else{
    oldPassword.addEventListener(MouseEvent.MOUSE_OUT,killToolTip);
    }

    Plz replay fast, i m in trouble
    Thanks
    Sandesh

    • kumargandhi says:

      Hi,

      destroyToolTip() method of the ToolTipManager Class will remove the ToolTip, here i suppose there’s some problem with the killToolTip() function you are using, you are not passing the event there, [MouseEvent], or try this logic,simply use this line if you want to remove the tooltip,
      oldpass.toolTip=””;//oldpass is TextInput Id i suppose
      so this line should go in to the else block of the above code[not in to the killToolTip() function].

      regards,
      kumar.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: