try and get ctrl-enter to add a clear all
[roojs1] / Roo / dd / DragDrop.js
index bfd52f5..c531e80 100644 (file)
@@ -26,6 +26,7 @@ var Dom=Roo.lib.Dom;
 
 /**
  * @class Roo.dd.DragDrop
+ * @extends Roo.util.Observable
  * Defines the interface and base operation of items that that can be
  * dragged or can be drop targets.  It was designed to be extended, overriding
  * the event handlers for startDrag, onDrag, onDragOver and onDragOut.
@@ -72,9 +73,10 @@ Roo.dd.DragDrop = function(id, sGroup, config) {
     if (id) {
         this.init(id, sGroup, config);
     }
+    
 };
 
-Roo.dd.DragDrop.prototype = {
+Roo.extend(Roo.dd.DragDrop, Roo.util.Observable , {
 
     /**
      * The id of the element associated with this object.  This is what we
@@ -563,7 +565,10 @@ Roo.dd.DragDrop.prototype = {
      */
     init: function(id, sGroup, config) {
         this.initTarget(id, sGroup, config);
-        Event.on(this.id, "mousedown", this.handleMouseDown, this);
+        if (!Roo.isTouch) {
+            Event.on(this.id, "mousedown", this.handleMouseDown, this);
+        }
+        Event.on(this.id, "touchstart", this.handleMouseDown, this);
         // Event.on(this.id, "selectstart", Event.preventDefault);
     },
 
@@ -788,6 +793,8 @@ Roo.dd.DragDrop.prototype = {
     unreg: function() {
         Event.un(this.id, "mousedown",
                 this.handleMouseDown);
+        Event.un(this.id, "touchstart",
+                this.handleMouseDown);
         this._domRef = null;
         this.DDM._remove(this);
     },
@@ -815,21 +822,31 @@ Roo.dd.DragDrop.prototype = {
      * @private
      */
     handleMouseDown: function(e, oDD){
-        if (this.primaryButtonOnly && e.button != 0) {
+     
+        if (!Roo.isTouch && this.primaryButtonOnly && e.button != 0) {
+            //Roo.log('not touch/ button !=0');
             return;
         }
+        if (e.browserEvent.touches && e.browserEvent.touches.length != 1) {
+            return; // double touch..
+        }
+        
 
         if (this.isLocked()) {
+            //Roo.log('locked');
             return;
         }
 
         this.DDM.refreshCache(this.groups);
-
+//        Roo.log([Roo.lib.Event.getPageX(e), Roo.lib.Event.getPageY(e)]);
         var pt = new Roo.lib.Point(Roo.lib.Event.getPageX(e), Roo.lib.Event.getPageY(e));
         if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) )  {
+            //Roo.log('no outer handes or not over target');
+                // do nothing.
         } else {
+//            Roo.log('check validator');
             if (this.clickValidator(e)) {
-
+//                Roo.log('validate success');
                 // set the initial element position
                 this.setStartPosition();
 
@@ -1157,6 +1174,6 @@ Roo.dd.DragDrop.prototype = {
         return ("DragDrop " + this.id);
     }
 
-};
+});
 
 })();