HTMLviewer Dropobject

Hello

I wanted to use the DropObject event on the HTMLviewer. But I cannot seem to find it in the event list? Dragenter, dragexit and dragover are available (but they’re not mentioned in the docs)

HTML is a subclass of RectControl, and RectControl has a DropObject, why doesn’t HTMLViewer has the event?

Cheers

If i remember it correct, HTMLViewer is a WebViewer and those do not expose all Events to the Hosting App. But AFAIK, you should be able to solve this by JavaScript injection.

Mac, Windows, Linux ?

Mac editor.

How should I solve this by Javascript injection? I want to dropText from a listbox to a HTML5 canvas. I tought I could acceptdrop on the HTMLViewer and than inject via JavaScript.

Because any subclass may implement the event and NOT expose it to the end user (you)
If it “implements” it with JUST a comment then the event is not available to you

Have you tried just dragging text into the web page you’re viewing ?
That may already work as the native class from Cocoa already handles a lot of this sort of thing without you having to do anything.

Thanks for answering people, I will have to solve this another way.

[quote=253616:@Norman Palardy]Because any subclass may implement the event and NOT expose it to the end user (you)
If it “implements” it with JUST a comment then the event is not available to you

Have you tried just dragging text into the web page you’re viewing ?
That may already work as the native class from Cocoa already handles a lot of this sort of thing without you having to do anything.[/quote]

I know how it’s technically done, I just don’t know WHY it is like this.

Maybe dropping just onto the page works, I will have to do it in HTML/JS.

Probably because the drop is handled by the OS object and not exposed to us so we can expose it to you
And because HTML/JS may override that as well

[quote=253611:@Mathias Maes]Mac editor.

How should I solve this by Javascript injection? I want to dropText from a listbox to a HTML5 canvas. I tought I could acceptdrop on the HTMLViewer and than inject via JavaScript.[/quote]

You have three ways available :

  • Put an input field or TextArea in your page where text can be dropped, instead of a canvas. It works with multiple objects. Even a file will appear as its path, or text dragged from somewhere else. You can use some javaScript to update your HTMLCanvas.

  • Lay a canvas over the HTMLArea. Make sure it does not become child. Implement me.AcceptTextDrop = true and DropObject. Of course you will have to use JavaScript to update the page with the text you get in the canvas dropobject. Note that this method is available only in Mac. In Windows, the canvas would intercept normal events operation.

  • Implement the drop in JavaScript in your HTML page.

I like these ideas they may help me with something similar that I had discounted trying out fearing that it would not work - thanks.

Note that these suggestions are made for the Mac platform.

Under Windows, any file dropped on the HTMLViewer will be opened or saved, so only text can be dropped on the TextField. To obtain the path of a file requires using some HTML5 and/or JavaScript code.

The canvas trick cannot be used, as the HTMLViewer intercepts the drop event.

What I want to do is to be able to drop media files onto a web page that HTMLViewer is displaying to get them queued for upload as part of a longer form filling exercise for the user. So I just need to detect the drop which I could not do for the same reason as the OP. However you made me think that maybe I could create a transparent control when the dragging starts and just catch the drop location with that and then use the execute js method to put the media file into the correct html input. It may not work but I will give it a try. The web page that I want to drop into is under my control so I have all options available. Thanks again.

If you are on Mac, the Canvas overlay is IMHO the easiest Xojo option.

Otherwise check http://www.sitepoint.com/html5-file-drag-and-drop/