Problem with event.getX or Y

I try to get the location of a field onSelection in the client Design Mode. I know that the location is x:0 and y:0 because I place it myself.

In the method onSelection(event):

var x = event.getX()
var y = event.getY()
application.output(x + ' / '+ y)

If I run the debugger the event.data returns x and y as 0, but the application output returns random values as “75 / 199” or “39 / 92”.

I also tried with event.data[0].getX() but it returns with an error.

what can I do to get the x and y from the data?

Is it possible for you to update to the latest Java version for MacOS X?
I noticed you’re using an older Java version (we’re at 1.6.0_22 now).

Hi Karel,
Thank you for reply.
I am using the latest version, I just forgot to update the signature. :oops:

event.getX() is the mouse position x not the element x.

to get the element x you should look “elements.myfield.” (as an example)
there you see that to get x you have to do getLocationX();

so

event.data[0].getLocationX();

Thank you Johan.
It works.