[whatwg] More questions about the DnD API

Daniel Cheng dcheng at google.com
Tue Mar 30 01:50:45 PDT 2010

On Tue, Mar 30, 2010 at 1:39 AM, Stef Epardaud <stef at epardaud.net> wrote:

> On Tue, Mar 30, 2010 at 01:31:15AM -0700, Daniel Cheng wrote:
> >      But then it's up to the developer to detect that the keys weren't
> >      pressed before (implement keydown events themselves), which is less
> >      practical.
> >
> >    If you're copying the behavior of file managers, isn't it simply a
> matter of
> >    setting dropEffect to whatever the current state of the modifier keys
> are?
> >    function dragOver(e) {
> >    Â Â if (e.ctrlKey) e.dropEffect = 'copy';
> >    Â Â else e.dropEffect = 'move';
> >    Â Â e.preventDefault();
> >    }
> >    I'm not sure how having separate keyboard events would help in this
> case,
> >    since you can't set dropEffect directly from a keyboard event.
> I want to do more than most file managers and let users visit
> subdirectories by pressing control while over them, so they can continue
> the drag operation inside the directory (and go deeper potentially).
> A separate event makes it much easier to detect the key press.
> >      But if I want to be notified that an external application started a
> drag
> >      in my document, where should I place the listener then? document?
> body
> >      node?
> >
> >    If an external application initiates a drag in your DOM page via the
> >    appropriate method for your platform, it should be the same as if a
> user
> >    initiated it. The dragstart event / drag events should end up getting
> fired
> >    at whatever node the application initiated the drag on. Maybe I'm
> >    misunderstanding your question though...
> No I mean, when an external application initiates a drag and then enters
> my browser window/document to look for potential places where it could
> drop it. I want to detect that and highlight all drop targets in the
> page. I would do this in the "drag" or "dragstart" events if this was
> started in the document, but how to do it when it is started by an
> external application?

I'd probably use a dragenter listener on the body of the document.

> --
> Stéphane Epardaud
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100330/c6a819dd/attachment-0002.htm>

More information about the whatwg mailing list