Cross platform drag and drop (replacing mousemove, mousedown and mouseup with ?)

edited December 2012 in General
I'm doing:
this.$.canvas.node.addEventListener('mousemove', enyo.bind(Tree, Tree.getMousePos), false);
this.$.canvas.node.addEventListener('mousedown', enyo.bind(Tree, Tree.onDragStart), false);
this.$.canvas.node.addEventListener('mouseup', enyo.bind(Tree, Tree.onDragEnd), false);
I tried changing the values (mousemove, mousedo..) to:
ondrag
ondown
onup
also tried:
drag
down
up
Both break the behavior of dragging a canvas circle, not working on my PC or Nexus 7 (Android) but on the Nexus 7 it doesn't work with or without the change, so basically I'm trying to get touch support, am I using the right events and just doing something wrong in Tree.getMousePos, Tree.onDragStart and Tree.onDragEnd or? Any ideas?

Comments

  • This isn't generally the Enyo way to get these events. Binding directly to the DOM's addEventListener can bypass Enyo's own event dispatching code.

    I'm not sure what "Tree" is in your code. However, usually you would setup handlers on the canvas instance. For example, you'd have a block
    handlers: {
        ondrag: "dragHandler",
        ondown: "downHandler",
        onup: "upHandler"
    }
    and that would result is local methods being called for those events. This would be in a new kind definition based on enyo.Canvas that you create.

    (BTW, use pre/code to surround code regions on the forum, not blockquote. The "C" button above the editor will do that for you.)
  • That worked like a charm, thanks!
Sign In or Register to comment.