WebHTMLViewer react on MouseDown/Up

Hey,

I’m looking into using a WebHTMLViewer to display an svg image scaled to the size of the control and this works just fine.
The problem now is that I want to detect MouseDown/Up on the WebHTMLViewer but those events don’t seem to fire.
I guess they don’t so that links can be used in the viewer…

Anyone know if mousedown/up can be detected on a WebHTMLViewer without placing a canvas or other control on top of it? :slight_smile:

I’m on 2013r3.3

[quote=192062:@Albin Kiland]Anyone know if mousedown/up can be detected on a WebHTMLViewer without placing a canvas or other control on top of it? :slight_smile:

[/quote]

You can detect MouseDown/Up in JavaScript, so it is possible to attach these events to a given element in the HTMLViewer DOM like your SVG. Problem is, it is an iFrame, which means the usual simple methods to return that to Xojo are not possible. I have not tested sending back an event to a WebSDK WebControlWrapper ; it could probably works but is a bit more involved.

The Canvas maybe the simplest way to go.

Thanks Michel,
I just solved it by building my control inside a container and putting a canvas over the HTMLViewer to stop the viewer from receiving the mousedown/up’s.
Now I can add the events to the container control on the page and they work as they should :slight_smile:

Thanks for taking a look at it :slight_smile:

FYI. Basically the order of the controls to get this working was:
ContainerControl -> WebHTMLViewer -> WebCanvas
Then I can implement MouseDown and/or MouseUp on the container when placed on a WebPage and they work as expected.

Amazing. Both WebContainer and WebCanvas get the MouseDown event. But if the canvas is not here, the WebContainer does not get the event…

Ouch. What I feared is happening. The canvas intercepts MouseWheel so the HTMLViewer stops scrolling.

Looks like back to JavaScript. But it won’t be as quick. I was just trying to access the body of a document inside an HTMLViewer and no luck so far.

Follow-up on JavaScript : sadly, I have to report that none of the techniques I know of to catch JavaScript events in the DOM work in an iFrame. Actually they would work only if what is displayed in the iFrame is on the same domain as the app.

The Canvas seems the only way to go. To restore scroll, you may want to have a really large HTMLViewer with the Canvas inside the WebContainer (the size of the HTML page), so it scrolls its content.

I also noticed that it was not possible anymore to click links inside the HTMLViewer.

Thanks M :slight_smile:
The way with the container - viewer - canvas works for me as I only display an svg image that is not meant to be scrolled, only clicked like a button :slight_smile:

I previously displayed the images in WebImageViews but putting an SVG in those don’t display in IE. When put into an HTMLViewer they do :slight_smile: