[whatwg] More questions about the DnD API

On Tue, Mar 30, 2010 at 12:38 AM, Stef Epardaud <stef at epardaud.fr> wrote:

> On Mon, Mar 29, 2010 at 02:04:22PM -0700, Daniel Cheng wrote:
> >      I'm still trying to use the DnD for a real-world use, and keep
> hitting
> >      problems. This is the HTML 5 draft at 7.9.4 Drag-and-drop processing
> >      model:
> >      "From this point until the end of the drag-and-drop operation,
> device
> >      input events (e.g. mouse and keyboard events) must be suppressed."
> >
> >    DragEvent (via MouseEvent) should expose ctrlKey, altKey, metaKey, and
> >    shiftKey properties.
>
> 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.


>
> >    dragstart and drag events are fired at the source node, but since
> you're
> >    dragging from a non-DOM application, you won't get any. You should
> still be
> >    getting dragenter / dragover / dragleave / drop if the item is
> >    dragged/dropped over a DOM page though. It works for me in WebKit.
>
> 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...


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

Received on Tuesday, 30 March 2010 01:31:15 UTC