[IGN-3917] ViewCanvas - Scripting - onClick event - ClientX/Y vs PageX/Y


I try to configure an event that get coordonate of the pointer based on the view. Actually all test I did with the event.client and the event.page coordonates gives me the same result coordonate.

My view is a ViewCanvas over a grid and that view will be embeded in an other view and I want to get coordonate from the child not the parent to be able to identify wich cell was clicked.


Browser click events do not supply the “relative” positioning of the event. Why do you need the coordinates? When I see questions like this, I have to ask why the instance being clicked could not return information about itself. For example, if you need to know which instance in the grid was clicked, why not supply each instance an “A-1” or “F-1” designation, and then use a message handler to broadcast which instance was clicked?

I can’t do that because the ViewCanvas is over the grid, so I clic on the ViewCanva and I need to know wich cell is under the pointer

I have to add pins on the grid via the ViewCanvas

Short of the “grid” being rendered within the Flex Repeater, I don’t see how you would accomplish this, just due to the limited information provided as part of the browser click event. It’s not a matter of us providing access to a property - the event we are provided by the browser does not contain the information you would need.

I got a functional solution by using a FIXED XY CONTAINER and by calculating position of my embedded grid according to margins and other embeded views size.

It’s not elegant but it’s a begining. I was thinking that the clientX/Y was relative to the object…

clientX/Y: The location in relation to the visible portion of the document. If you click point A, then scroll the page, then click again without having moved the mouse, a subsequent click will return the same value because your X/Y position within the visible area has not changed. This has no relation to the component.

pageX/Y: The location in relation to the entire document (page). If you click point A, then scroll the page, then click again without having moved the mouse, a subsequent click will return a different value, because the Y position is no longer the same as the first click.

screenX/Y The location in relation to the actual physical monitor screen. Scrolling will have no effect on these values. They do no correlate to the session/page - only to the user’s monitor.

I try to setup onInstanceClicked but it looks like it doesn’t fired.

onInstanceClicked will only fire for actual elements you have in the view canvas. How is your grid drawn?

Sorry, don’t know why but I think gateway wasn’t update my view. It works now

My ViewCanvas is over my grid

I try to get a params value and I don’t understand the result

event.params[“column”] must return 0

but I get {"$":[“qv”,192,1629392497768],"$v":0} instead of jut the 0

What is your exact script? That’s an ‘encoded’ value used for communication between Perspective’s frontend and backend; you’re not supposed to ever have to deal with those.

To get my value I have to add ["$v"]

system.perspective.print("instance fired - index:" + str(event.index) + " / col: " + str(event.params["column"]))


That behavior is incorrect. Your workaround will work for now, but will break when we fix the issue I’ve just opened to rectify this undesired behavior.

Do you have solution for me instead of using flexrepeater and ViewCanvas ?

I want a grid that I can place a dynamic objects to get states of sensors

Number of rows, columns and sensors must be dynamique

No, this approach is what you’re looking for - it just happens to be a bit broken.