Changeset 7767

Show
Ignore:
Timestamp:
03/22/07 19:42:45 (20 months ago)
Author:
elazutkin
Message:

dnd2: added onkeydown/onkeyup handlers to watch for copy/move status, minor cleanup of the source

Location:
trunk/src/dnd2
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/dnd2/manager.js

    r7766 r7767  
    4747                dojo.event.connect(dojo.doc(), "onmousemove", this, "onMouseMove"); 
    4848                dojo.event.connect(dojo.doc(), "onmouseup",   this, "onMouseUp"); 
     49                dojo.event.connect(dojo.doc(), "onkeydown",   this, "onKeyDown"); 
     50                dojo.event.connect(dojo.doc(), "onkeyup",     this, "onKeyUp"); 
    4951                dojo.html.addClass(dojo.body(), "dojoDnd" + (copy ? "Copy" : "Move")); 
    5052        }, 
     
    6163                dojo.event.disconnect(dojo.doc(), "onmousemove", this, "onMouseMove"); 
    6264                dojo.event.disconnect(dojo.doc(), "onmouseup",   this, "onMouseUp"); 
     65                dojo.event.disconnect(dojo.doc(), "onkeydown",   this, "onKeyDown"); 
     66                dojo.event.disconnect(dojo.doc(), "onkeyup",     this, "onKeyUp"); 
    6367                this.avatar.destroy(); 
    6468                this.avatar = null; 
     
    7478                        s.left = (e.pageX + 10) + "px"; 
    7579                        s.top  = (e.pageY + 10) + "px"; 
    76                         if(this.copy != e.ctrlKey){ 
    77                                 this.copy = e.ctrlKey; 
    78                                 this.source.markDndStatus(this.copy); 
    79                                 this.updateAvatar(); 
    80                                 dojo.html.replaceClass(dojo.body(), "dojoDnd" + (this.copy ? "Copy" : "Move"), "dojoDnd" + (this.copy ? "Move" : "Copy")); 
    81                         } 
     80                        if(this.copy != e.ctrlKey){ this.setCopyStatus(e.ctrlKey); } 
    8281                } 
    8382        }, 
     
    9190                        this.stopDrag(); 
    9291                } 
     92        }, 
     93        // keyboard event processors 
     94        onKeyDown: function(e){ 
     95                if(this.avatar && e.keyCode == dojo.event.browser.keys.KEY_CTRL && !this.copy){ this.setCopyStatus(true); } 
     96        }, 
     97        onKeyUp: function(e){ 
     98                if(this.avatar && e.keyCode == dojo.event.browser.keys.KEY_CTRL && this.copy){ this.setCopyStatus(false); } 
     99        }, 
     100        // utilities 
     101        setCopyStatus: function(copy){ 
     102                this.copy = copy; 
     103                this.source.markDndStatus(this.copy); 
     104                this.updateAvatar(); 
     105                dojo.html.replaceClass(dojo.body(), "dojoDnd" + (this.copy ? "Copy" : "Move"), "dojoDnd" + (this.copy ? "Move" : "Copy")); 
    93106        } 
    94107}); 
  • trunk/src/dnd2/source.js

    r7766 r7767  
    4242        this.mouse_down = false; 
    4343        this.target_anchor = null; 
    44         this.target_valid = false; 
    4544        this.before = true; 
    4645        // states