Controlling the X and Y Positions for a ToolTip.

710 views
Skip to first unread message

malavika

unread,
Sep 2, 2008, 1:21:34 PM9/2/08
to Flex India Community
Hi Everyone,
I have a serious problem of controlling the X and Y position
for a ToolTip. I have a datagrid for populating the data over it. When
the mouse is rollovered on the one of the column I'm poppingup a
tooltip. As the mouse is moved over the text in that column the
tooltip position is changing according to that. I could not really
understand how to make the position stable. At the same time even i
could not hardcode the x and y position of the tooltip.

My Code :
var square:Sprite = new
Sprite();
var positionX:Number = square.mouseX
var positionX:Number = square.mouseY
myToolTip =
ToolTipManager.createToolTip(text,positionX,positionY) as ToolTip;



Thanks,
Malavika.

Venkat Viswanathan

unread,
Sep 2, 2008, 3:14:04 PM9/2/08
to flex_...@googlegroups.com
Hi Malavika,

Inside the itemRenderer, put this code:

var pt:Point = new Point(0,0);
this.localToGlobal(pt);

This will help you get the global x,y co-ordinates for individual itemRenderers.

Let me know if this still doeskin solve your problem.

Regards,
Venkat
www.venkatv.com
Message has been deleted
Message has been deleted

malavika

unread,
Sep 3, 2008, 2:45:18 PM9/3/08
to Flex India Community
Hi Venkat,
Thanks for the quick reply. This is the function that has been
called on the rollover event. when the mouse is been placed over the
column(the data in the tooltip will be changed dynamically when it is
placed over each row) this function is been called. The ToolTip is
appearing all through the row of that column. Instead of appearing on
the data.

public function DisplayToolTip(event:MouseEvent):void{
var text:String;
var square:Sprite = new Sprite();
var positionX:Number = square.mouseX
var positionY:Number = square.mouseY

text = "Field Values are : "+"\r"+"\n";
text += "Materail Number:" +"
"+event.target.data.Mat_number
+"\r"+"\n";
text += "Item Description:" +"
"+event.target.data.Item_desc
+"\r"+"\n";

myToolTip =
ToolTipManager.createToolTip(text,positionX,positionY) as ToolTip;
myToolTip.setStyle("color","#000000");
myToolTip.width = 125;
myToolTip.height = 70;
}

I tried of putting your code inside this function. But could not find
out the change. I suppose i might have made the mistake.


Regards,
Malavika.

On Sep 3, 12:14 am, "Venkat Viswanathan" <helloven...@gmail.com>
wrote:
> Hi Malavika,
>
> Inside the itemRenderer, put this code:
>
> var pt:Point = new Point(0,0);
> this.localToGlobal(pt);
>
> This will help you get the global x,y co-ordinates for individual
> itemRenderers.
>
> Let me know if this still doeskin solve your problem.
>
> Regards,
> Venkatwww.venkatv.com
>

malavika

unread,
Sep 4, 2008, 11:52:24 AM9/4/08
to Flex India Community
Hi,
I have even tried using the the below code's but still couldn't
get the position of the tooltip changing dynamically.

Code 1:
myTip = ToolTipManager.createToolTip(s,
event.currentTarget.x + event.currentTarget.width
+ 10,
event.currentTarget.y)
as ToolTip;

Code 2: var pt:Point = new
Point(0,height);
pt = localToGlobal(pt);
pt = root.globalToLocal(pt);
myTip =
ToolTipManager.createToolTip(s,pt.x,pt.y) as ToolTip;

Regards,
Malavika.
Reply all
Reply to author
Forward
0 new messages