EasyUI Forum
June 15, 2024, 05:36:14 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: prevent right click unless defined  (Read 4573 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: June 17, 2014, 04:27:21 AM »

Code:
$(document).on("contextmenu",function(e){e.preventDefault()});

This will of course prevent all right mouse clicks, but how can I prevent right mouse clicks UNLESS they have been defined within easyui using for example onContextMenu ?

I want to disable right mouse clicks in all areas, unless I have allowed them.
 
« Last Edit: June 17, 2014, 04:34:36 AM by devnull » Logged

-- Licensed User --
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 17, 2014, 06:20:13 PM »

The e.target value indicates what element is clicked. You can detect events bonded to it or other informations to determine if the event should be cancel.
Code:
$(document).on('contextmenu',function(e){
var target = e.target;
var events = ($.data(target,'events')||$._data(target,'events'))
//...
})
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!