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

**URL:** <https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099>\
**Category:** Ignition Early Access\
**Tags:** ignition80, ignition81, perspective\
**Created:** [August 19, 2021, 1:03pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099 "2021-08-19T13:03:54Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 1:03pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/1 "2021-08-19T13:03:54Z")

</div>

8.1.9

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.

![2021-08-19_09h01_54](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/4/04b62f5c9a49eae3b2faddfd268ab24681f93008.gif)  
 ![2021-08-19_09h03_08](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d414f43afbd8af6190d5e2082d825e741736dfd.gif)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 19, 2021, 1:46pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/2 "2021-08-19T13:46:54Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 2:00pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/3 "2021-08-19T14:00:26Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/1/3199a28b6e1e614f2a87ef1e1b6dd8b5f668990d.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 19, 2021, 3:23pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/4 "2021-08-19T15:23:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 3:32pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/5 "2021-08-19T15:32:11Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 19, 2021, 3:53pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/6 "2021-08-19T15:53:05Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 4:31pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/7 "2021-08-19T16:31:49Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/5/d54a2827c821f8d13d0024b675a911943bc2cf07.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 19, 2021, 4:33pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/8 "2021-08-19T16:33:03Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 4:34pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/9 "2021-08-19T16:34:43Z")

</div>

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

My ViewCanvas is over my grid

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 5:05pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/10 "2021-08-19T17:05:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 19, 2021, 5:08pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/11 "2021-08-19T17:08:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 5:10pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/12 "2021-08-19T17:10:12Z")

</div>

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

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

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/6/d6b41508c6f10a1f69bc3d3815ef3dfe5cb2a2f1.png)

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 19, 2021, 5:48pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/13 "2021-08-19T17:48:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luc.martin](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@luc.martin](https://forum.inductiveautomation.com/u/luc.martin)\
**Post date:** [August 19, 2021, 6:23pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/14 "2021-08-19T18:23:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [August 19, 2021, 7:05pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/15 "2021-08-19T19:05:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [December 1, 2021, 10:24pm UTC](https://forum.inductiveautomation.com/t/ign-3917-viewcanvas-scripting-onclick-event-clientx-y-vs-pagex-y/50099/16 "2021-12-01T22:24:16Z")

</div>

This issue was resolved as part of the 8.1.12 release.
