How to get CharacterPosition for WebTextArea?

I am trying to convert TTsDIFF from Desktop to Web and it requires getting the CharacterPosition for a given x,y within a WebTextArea, but WebTextArea has no CharacterPosition method e.g.

Dim x, y, d, pos, pos2 As Integer
pos2 = editf.CharacterPosition(x, y)

Is there a workaround for getting the CharacterPosition for a WebTextArea?

FWIW, in API1 it used to be called editf.CharPosAtLineNum(x) and editf.CharPosAtXY(x, y).

Not currently possible, and not a feature I’d attempt to support in the framework. This would vary wildly by the Bootstrap theme used and any additional styles that may be applied to the WebTextAreas.

The TTsDIFF currently uses a mono-spaced font with no wrapping on Desktop to work and I would be happy to maintain this.

There’s also padding, margins, character spacing, and more that would need to be taken in to account in an implementation built in to the Xojo framework to ensure that it works everywhere. All of which can vary by Bootstrap theme, target browser, user system language, and individual user implementations.

I’m not saying it can’t be done for very specific scenarios, I’m saying that it’s not a good idea to add it to the Framework. The calculations would need to occur server-side based on client-side conditions as Web is asynchronous.

1 Like

I will need to rethink my solution and tone down the expectations. Thank you @Anthony_G_Cyphers.