Saturday, February 20, 2010

How to get absolute x and y from element inside HBox?

So you want the buttons inside the HBox, but the arrows outside the HBox, and therefore need a way of converting the local x,y coordinates of your buttons to global ones?

This will give you a global point:
myButton.localToGlobal( new Point( myButton.x, myButton.y ) );


Notes:
* localToGlobal shold be invoked from the button's inmmediate parent (hbox).
* this.globalToLocal needed to translate the obtained coords for the app
* use contentToGlobal and globalToContent instead to avoid problems with padding from the hboxes

No comments:

Freelance