Discussion Forums  >  Uncategorized

Replies: 0    Views: 361

CBungert
Aspiring developer
Profile
Posts: 56
Reg: Jun 17, 2011
Minneapolis
3,310
01/23/12 04:52 PM (14 years ago)

How to convert right click to touch event in Java /jquery?

hopefully someone here can help me, even if not, if ill find a simple solution I'll post back my findings here to try to help others. But, I am trying to convert the right click event below into be a Long Press touch event, or even the gesture, oneFingerSwipeDown... Everything I have tried breaks all touch detection. (The Code below works perfectly when using a mouse, and everything works correctly on an iPad, however, the function is basically left click to add points, right click to subtract and really all I need is a way for the right click function to be controlled by a different action / gesture... because iOS has no right click if(jQuery) (function(){ $.extend($.fn, { rightClick: function(handler) { $(this).each( function() { $(this).mousedown( function(e) { var evt = e; $(this).mouseup( function() { $(this).unbind('mouseup'); if( evt.button == 2 ) { handler.call( $(this), evt ); return false; } else { return true; } }); }); $(this)[0].oncontextmenu = function() { return false; } }); return $(this); }, rightMouseDown: function(handler) { $(this).each( function() { $(this).mousedown( function(e) { if( e.button == 2 ) { handler.call( $(this), e ); return false; } else { return true; } }); $(this)[0].oncontextmenu = function() { return false; } }); return $(this); }, rightMouseUp: function(handler) { $(this).each( function() { $(this).mouseup( function(e) { if( e.button == 2 ) { handler.call( $(this), e ); return false; } else { return true; } }); $(this)[0].oncontextmenu = function() { return false; } }); return $(this); }, noContext: function() { $(this).each( function() { $(this)[0].oncontextmenu = function() { return false; } }); return $(this); } }); })(jQuery); Im pretty sure this is possible, and maybe even easy...
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.