Page 1 of 1

Problem with event.getX or Y

PostPosted: Wed Nov 17, 2010 4:26 pm
by irenem
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):
Code: Select all
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?

Re: Problem with event.getX or Y

PostPosted: Wed Nov 17, 2010 5:02 pm
by Karel Broer
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).

Re: Problem with event.getX or Y

PostPosted: Wed Nov 17, 2010 5:21 pm
by irenem
Hi Karel,
Thank you for reply.
I am using the latest version, I just forgot to update the signature. :oops:

Re: Problem with event.getX or Y

PostPosted: Wed Nov 17, 2010 5:40 pm
by jcompagner
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();

Re: Problem with event.getX or Y

PostPosted: Wed Nov 17, 2010 5:54 pm
by irenem
Thank you Johan.
It works.