Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:10:21+00:00 2026-05-30T18:10:21+00:00

I am updating/debugging and expanding the capabilities of my draggable script and I need

  • 0

I am updating/debugging and expanding the capabilities of my draggable script and I need to be able to achieve the following result:

whatever.onRightMouseButtonMousedown = preventDefault();

I have done a lot of research to no avail, however, I know that it is possible to do this because when I use jquery-ui draggable, it prevents the ability to drag elements when you mousedown with the right mouse button. I want to mimic this ability, and learn how it works so that I can implement it now and in the future as needed.

Note: Please do not give me information about how to use jquery or jquery-ui draggable (I already am familiar with it), I want to learn how they implemented, or how it is possible to implement the detection of a mousedown with the right mouse button so that I can prevent elements from being draged with the right mouse button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:10:22+00:00Added an answer on May 30, 2026 at 6:10 pm

    Normally when you have any kind of mouse event, you’ll want to have it only operate on one type of mouse click. Therefore, the events passed to your callbacks have a property which allow you to distinguish between types of clicks.

    This data is passed back through the button property of the event data. See MDN for finding out what values represent what data.

    Therefore, you don’t disable the right click, you instead only enable your functionality for the left click. Here’s a [poor] example:

    element.onmousedown = function(eventData) {
      if (eventData.button === 0) {
          alert("From JS: the (left?) button is down!")
      }
    }  
    

    the equivalent in jQuery is:

    $("div").mousedown(function(eventData) {
        if (eventData.which === 0) {
            alert("From JQuery: which=" + eventData.which)
        }
    });
    

    Note that if you don’t use jquery, the values returned will be different across browsers. jQuery unifies the values across browsers, using 1 for left, 2 for middle, 3 for right:

     element.onmousedown = function(eventData) {
       if (eventData.button === 0) {
         console.log("From JS: the (left?) button is down!")
       }
     }
    
     $("#element").ready(function() {
       $("div").mousedown(function(de) {
         console.log("From JQuery: which=" + de.which);
       });
     });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div id="element" style="width: 100px; height: 100px; background-color: blue" />
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When updating a row, I want to have a built-in check to do some
I have a simple model FilesModel for updating a string Description and the boolean
after updating my grails app's security plugins, i get the following error when deploying
I'm having trouble with updating an ASP:UpdatePanel using javascript (jQuery). Here're what I have.
I have an update database operation, that has an activity, which keeps updating the
After updating a bundle, you will have some gems that may be obsolete --
Since updating to the latest JQuery I have noticed that all my getJson calls
I've been updating an existing library to throw exceptions to help improve debugging by
A python program that I'm debugging has the following code (including print statements for
Updating from Cake 1.2 to 1.3 and I have an image nested in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.