lundi 26 mai 2014

'Before' the context menu on right click


Vote count:

0




I have an idea (just woke u so I am a little fuzzy), I was thinking of a way to clear a div of its content on right click before the normal context menu comes up.


Is this good code for the job and is this even necessary? Does the context menu react to mouse down or is it mouse up)? Is there time for an event to fire in between a fast click before the context menu appears?


Is the context menu like an alert in that it pauses execution of code?



var specialcase=0,
, element=null,
, ev=null;


$('#element').bind("contextmenu",function(e){
if(specialcase===1){
specialcase=0;
e=ev;
//this=element; <- might not be needed
//act on right click event from mouse down
}
else{//normal behavior
}
});



$('#element').mousedown(function(event){
if(event.which===3){
//do something to this element before context menu
e.preventDefault();
specialcase=1;
element=this;
ev=e;
$('#element').trigger("contextmenu");
}
});


asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire