PDA

View Full Version : righ mouse click - context menu vs drag'n'drop - measure click-hold time



johnrembo
7 Oct 2010, 2:55 AM
Hello,

a couple of questions I've been unable to find answers to for a while:

1. How can I initiate right-click drag'n'drop on i.e. tree node? (for the right-handed mouse)
2. How can I measure for how long certain mouse click was holded before released (to i.e. start dragging if delay is >1sec, and show context menu if delay is ,1sec)

I am asking this, because my application requires to have:
a) right-click "create shortcut here" feature on a Tree
b) context menu for right-clicks
c) DD option

I am looking for some events to look at, and the only one I've found that seems to relate to 1. is "primaryButtonOnly" in Ext.dd.DD

thank you!

johnrembo
7 Oct 2010, 11:06 AM
nevermind, got this working


Ext.ns('TPConfig');
TPConfig.moveEventDetected=false;

var TP = new Ext.tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
ddAppendOnly: true,
loader: new Ext.tree.TreeLoader({
dataUrl: 'http://localhost/tree.php',
}),
root: new Ext.tree.AsyncTreeNode({
expanded: true,
editable:true,
text:'ROOT'
}),
/*dragConfig: { // CAN't understand why, but this doesn't work - I had to use load event to set this to true
primaryButtonOnly:false
},*/
dropConfig: {
appendOnly: true,
onNodeOver : function(dst, dd, e, src){
TPConfig.moveEventDetected=true;//indicate object is dragable
return Ext.tree.TreeDropZone.prototype.onNodeOver.call(this,dst,dd,e,src);
},
onNodeDrop : function(dst, dd, e, src){
if (isDropAllowed(src,dst)) {
return Ext.tree.TreeDropZone.prototype.onNodeDrop.call(this,dst,dd,e,src);
}
TPConfig.moveEventDetected=false;
return false;
}
},
listeners:{
load:function(node){
this.dragZone.primaryButtonOnly=false;
},
append:function(tree,parent,node,index) {
parent.expand();
TPConfig.moveEventDetected=false;
}
}
});

TP.on('contextmenu', myContextMenu, this);