How to get reliable x and y coordinates in Android?

A simple test project demonstrates an issue (tested from Mac OS 12):
• Put a WebCanvas and a WebLabel to the default page.
• In the WebCanvas’ Pressed event, put: Label1.Text=x.ToString+", "+y.ToString
• Run the project. With an Android phone (and Firefox, in my test), connect to the web app (http://ipofcomputer:8080).
• Click where the (transparent) canvas is, several times, and at several places. Notice the label shows odd values (“0, 0”, “7, 0”, etc.).
• This works fine on Mac, but not on Android (and not Windows, too, I believe).

I need to get the correct x and y values in a project; that’s an important part of it. Can this be done otherwise, like with Javascript?

On Windows, Firefox or Chrome, works fine using mouse. Shows the x,y point pressed.

On Android, using Chrome, shows 0,0, just denoting “touched”, but no coordinate.

Bug in Xojo, report.

// This seems to work everywhere:

1 Like

Thank you.

Good to know. I’ll check various combinations to tell my users what currently works.

Like Firefox. I’m wondering whether clicking works on Android at all, for Xojo apps.

Already done :wink: (still in “need review” state, though).

I’ll give it a try. Since my existing Xojo canvas is already almost complete, I’ll try to merge this script to the canvas. For this to work, I’ll need to pass the Javascript event back to Xojo; brand new to me.

Thank you.

1 Like

Not merge. Understand and adapt. It’s not usable as is. :wink:

Cleaned up a bit more: Edit fiddle - JSFiddle - Code Playground

Hmm… Perhaps I was not clear.
I already have a Xojo WebCanvas with slightly complex drawing working. Re-doing all the drawings in Javascript would take me ages, especially as I’m not an expert in that language.
Instead, I’m looking for adding the OnClick event to the existing Xojo WebCanvas (that’s what I called “merge”) because the existing Pressed event in Xojo is broken.
But I need that Javascript event to come back to my Xojo’s already existing code and I can’t see how to receive a JS event in Xojo…
I can’t convert the Pressed event’s code to JS either (all is already done in Xojo).

Am I missing something?