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 6789271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:35:02+00:00 2026-05-26T17:35:02+00:00

My problem is whenever I left click a dynatree node then right click another

  • 0

My problem is whenever I left click a dynatree node then right click another dynatree node to display my context menu the node which was left clicked remains highlighted in blue so I end up with two nodes in blue. If I then right click successive nodes the highlighting works correctly but the left clicked node remains highlighted.

The left click processing clears the previous node on mouseup. I initiate context menu processing via

document.oncontextmenu=contextMenu 

which is also called on mouse up.

I have tried to capture the right button mouseup event and make the context menu node active thinking that would change the state of the left clickked node but not so.

$("#tree").mouseup(function(e){
   if(e.button == 2){
      e.target.setActive();// right mouse up
  }     
}); 

How should I get the last left clicked node to unhighlight when another node is right clicked ? It does not look right to have two nodes highlighted at once. I have noticed the dynatree context menu demo does not unhighlight the previously left clicked node when another node is right clicked so is this by design ?? Can you get around it ?

Thanks,
Al

  • 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-26T17:35:02+00:00Added an answer on May 26, 2026 at 5:35 pm

    OK this works

    In my myfile.js after I create the dynatree I added:

    var dtnode;   //dynatree node Global <--ADDED
    var elem;     //DOM node Global  <--ADDED
    
    
    Function BuildTree()
    
    
    //ADDED following code after the dynatree was loaded 
    
    $("#tree").mouseup(function(e){
    if(e.button == 2){ //RIGHT MOUSE UP 
        if(!(elem == null)){
            var elem2 = e.currentTarget.document.activeElement;
            dtnode = tree.getDtNodeFromElement2(elem);
            dtnode.deactivate();
            elem = null;
            }   
    }else{//LEFT MOUSE UP
        if(!(elem == null)){
            elem = null;
        }
        elem = e.currentTarget.document.activeElement;  
    }   
    }); 
    
    //In jquery.dynatree.js
    //$Version: 1.1.1$
    //$Revision: 481, 2011-03-02 07:25:35$
    
    //The following changes were made:
    
    getSelectedNodes: function() {
        return this.tree.getSelectedNodes();
    },
    
    // AFTER THE ABOVE FUNCTION THE FOLLOWING FUNCTION WAS ADDED
    
    getDtNodeFromElement2: function() {
        return this.tree.getDtNodeFromElement2();
    },
    
    //********************************************************
    
    getSelectedNodes: function(stopOnParents) {
        var nodeList = [];
        this.tnRoot.visit(function(node){
        if( node.bSelected ) {
            nodeList.push(node);
            if( stopOnParents === true ){
               return "skip"; // stop processing this branch
            }
        }
    });
    return nodeList;
    },
    
    // AFTER THE ABOVE FUNCTION THE FOLLOWING FUNCTION WAS ADDED 
    
    getDtNodeFromElement2: function(elem) {
        var sourceNode = getDtNodeFromElement(elem);
        return sourceNode;
    },
    

    Summary:
    By keeping track of the last element to be left clicked and exposing the dynatree getDtNodeFromElement method through getDtNodeFromElement2 it is possible to call the deactivate method on the last left clicked node whenever the first right click of a node occurs. This eliminates simultaneous highlighting of tree nodes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

problem is , that whenever the grid's row is right clicked the selected item
If I right click on my project and select properties. Then select android properties
Whenever I see a problem that would be shared by others, with a solution
I encountered a strange problem today. Whenever i put a breakpoint in one of
I have a problem with using the prefix, seems like whenever I use the
I am getting this annoying problem, whenever i do some changes to any file
I'm having an annoying problem with my iPhone app. Whenever I set the optimization
Problem: I have an address field from an Access database which has been converted
I am having strange problem, whenever my site is loaded for the first time
The problem I have is that whenever I try to drag and drop with

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.