Hi Hans -

Looks like there is a bug in Menu where the the conversion of coordinates
from the space of myBox to the global Application space is not working. I've
filed a bug internally for this.

As a workaround, you will have to manually do this conversion using
localToGlobal(). Below is code that works. 

Note: if and when we do chose to fix this bug - anyone already doing this
manual conversion will have to amend their code. 

Hope this helps -
Deepa
Flex Team

--->
<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>

<mx:XML id="myDataProvider">
<node label="Main">
<node label="Inner" />
</node>
<node label="Main">
<node label="Inner" />
</node>
</mx:XML>

<mx:VBox>
<mx:HBox id="myBox" backgroundColor="#EFEFEF">
<mx:Link id="l" label="Open Menu"
click="createAndShow(event)"/>
<mx:Link label="Open Menu2" click="createAndShow(event)"/>
</mx:HBox>
</mx:VBox>

<mx:TextArea id="debug" width="200" height="200" />

<mx:Script><![CDATA[

import mx.controls.Menu;

function createAndShow(event){
var myMenu:Menu = Menu.createMenu(myBox, myDataProvider);
var point = new Object();
point.x = event.target.parent.x;
point.y = event.target.parent.y + event.target.parent.height;
myBox.localToGlobal(point);
myMenu.show(point.x, point.y);
}


]]></mx:Script>

</mx:Application>

-----Original Message-----
From: Hans Omli [mailto:[EMAIL PROTECTED] 
Sent: Thursday, May 06, 2004 7:59 AM
To: [email protected]
Subject: [flexcoders] Need help positioning a menu component

I'm having a heck of a time positioning menus. I've got a set of 
Link components within a HBox container which is within a VBox 
container.

<mx:VBox>
<mx:HBox id="myBox">
<mx:Link label="Open Menu" click="showMenu(event)"/>
<mx:Link label="Open Menu2" click="showMenu(event)"/>
</mx:HBox>
</mx:VBox>

The showMenu() function looks like this:

function createAndShow(event){
var myMenu:Menu = Menu.createMenu(null, myDataProvider);
var myX:Number = event.target.x;
var myY:Number = event.target.y + event.target.height;
myMenu.show(myX, myY);
}

When I click on the link, I would like the menu to appear directly 
below the link. However, rather than appearing directly below the 
link, it is appearing at position x=0, y=22. The value of myX is 0 
and of myY is 22, which must be the position of the link within the 
HBox?

I tried changing the createMenu function from null to myBox--the id 
assigned to the HBox. I also tried using LocalToGlobal. Haven't 
had any luck yet though. What am I missing here???





Yahoo! Groups Links






Reply via email to