OK, let’s say that I have a HTMLViewer control (now DesktopHTMLViewer I believe?) on a document window. I load an URL in it and then I want my Javascript events to fire up for MouseDown. How do I do that? For some reason, nothing happens when I click in the canvas inside of my HTML app. When I load the same URL in Firefox or Edge, it works as expected. (and no, there aren’t any external resources missing or not loading)
Additional question afterwards: Is it possible to comply with the Javascript API requestPointerLock() ? If so, how? Or I guess once we figure out how to pass click events to the HTML app inside the HTMLViewer, it will be sorted out intrinsically?
There must be something I really don’t understand compared to RealBasic, but how exactly am I supposed to add this MouseDown event to the HTMLViewer control?
What you are asking is unclear. A mousedown inside an HTMLViewer is taken by the Viewer; no Xojo MouseDown event occurs as far as I can see from testing. If you have some html objects inside the page that you load into the Viewer, and one of those has an onclick handler then that html element’s handler will fire and execute whatever javascript you have in the handler.
There are some technical limitations on a few controls. One of them happens to be that HTMLViewer doesn’t have mouse tracking, you need to do that with Javascript.
My bet, though, is that you could do whatever it is you’re about to do with WebCanvas can be done in Xojo code on a DesktopCanvas without anywhere near as much waste.
The canvas I was referring to is just a HTML canvas, rendering WebGL contents. When clicking in it, it’s supposed to capture the mouse pointer. It does in a regular web browser, but it does not in the Xojo HTMLViewer.
That said, (Desktop)HTMLViewer does not implement everything a browser does. There may very well be things that just don’t work. Have you tried looking for a more appropriate tool to build your project?
I think this is a deal breaker for this project. If I understand you correctly, there is no way as of now in Xojo to capture the mouse pointer, pin in the center of screen and read raw X/Y deltas much like Javascript requestPointerLock() does, correct? Because if there was a way to read raw X/Y cursor deltas, then I could use ExecuteJavaScript to pass the deltas and mimick Javascript requestPointerLock() manually.
Hmm, I’m not actually sure about that specific need. I know that a browser can’t hold my mouse hostage unless it’s in fullscreen mode, and I’m not sure fullscreen mode is something that works within the XojoHTMLViewer universe. The people who have tried to wrap streaming services might know more about if that’s possible.
Ok, Dwight.
Good luck with your project, I was only trying to point out failure points I could foresee.
I wasn’t thinking about clicking inside a canvas to provide it that privilege.
Thanks for the name calling I guess? If what you post is false, then it’s false, like there’s no need to be offended by a simple fact. And don’t you forget that I’m one of the TWO new users of the month who deserved a badge!
OK well I’m sorry man! I didn’t mean to offend anybody? I appreciate the help, always! EVEN YOURS!
Can we go back to the topic now?
So basically, we’re not aiming for going fullscreen. We’re aiming for capturing the mouse pointer so that we can infinitely move the cursor in any direction without hitting the border of the screen. That’s what the JS counterpart does and that’s what I need to mimick in Xojo to be able to pass the mouse X/Y deltas to JS to mimick what requestPointerLock() is doing natively in a real web browser.
HTMLViewer is not fully implemented to support every API you expect in a browser. Anything that requires user approval like location, camera, microphone, notifications, etc. just won’t work. I haven’t investigated the API you want to use myself, but if it typically requires user approval, it probably just won’t work.
There’s probably a way you could implement this with Xojo’s HTMLViewer, just maybe not using that API.
OK that’s precisely why requestPointerLock() does not fire up. It’s clear. But how can I natively mimick this in Xojo? Let’s strictly talk about how to do this in Xojo, nevermind Javascript or the HTMLViewer, I’ll pass values later to it once I figure out how to do it in Xojo. Should I make a new topic for this?
Well, abstractly, you’d need to lock the mouse to a screen position, get notified of changes to position, then send that to the viewer to raise the mouse move event on the canvas node.
I’ve never had a need for manipulating the cursor like this and usually consider it bad form, so I can’t be more specific.
An alternative would be to also implement what you need using drag events in your JavaScript.