In WebKitGtk+, how can I access parameters in an event listener?

Posted by Matthew on Stack Overflow See other posts from Stack Overflow or by Matthew
Published on 2012-06-18T21:13:48Z Indexed on 2012/06/18 21:16 UTC
Read the original article Hit count: 294

Filed under:
|
|
|
|

Here is an example in javascript of what I want to do:

function handleDragStart(e) {
  e.dataTransfer.effectAllowed = 'move';
  e.dataTransfer.setData('text/plain', 'some data');
}

var dragSource = document.querySelector('#dragSource');
dragSource.addEventListener('dragstart', handleDragStart, false, null);

But I am having trouble translating this to a GLib-based system. Here is an example in Vala:

void on_dragstart(EventTarget event_target) {
    // How can I access the equivalent of e.dataTransfer?
}

WebKit.WebView web_view = ...
WebKit.DOM.Document document = web_view.get_dom_document();
WebKit.DOM.Element drag_source = document.query_selector('#dragSource');
drag_source.add_event_listener("dragstart", (Callback) on_dragstart, false, null);

While I am using Vala, an answer in any language interacting with WebKitGtk+ directly would be helpful.

© Stack Overflow or respective owner

Related posts about webkit

Related posts about gtk