70001991 How to display something by right click when action is active

Article 70001991
Type HowTo
Product WebJS
Version 8
Date Added 6/1/2021 12:00:00 AM
Fixed 9.9002.0.3 (6/2/2021 12:00:00 AM)
Submitted by Bogumil Styczen

Summary

How can i display something like a pop up window or an alert window by right clicking when an action is active.

Solution

In the example bellow we will use the vdmousedown event in order to catch the right click, we will raise an alert window without finish or cancel the action.

 
      vdcanvas.vdmousedown = _vdmousedown;// set the vdmousedown event on the initialize page load of canvas element. You could use also the vdmouseup event

      function _vdmousedown(e) {

            if (e.mousebutton > 1) {// that means that user press the right click
                var action = e.target.ActiveAction(); //get the action so if you display a menu with right click, then you could use it as an option
                // in order to finish the action like: MyCustomActionFinish(action); before call the e.Cancel = true;
                alert("Mouse Down Right Click"); // here you could display your menu               
                e.Cancel = true; // call cancel=true in order not to cancel or finish the active action. NOTE if you do not call e.Cancel=true the action will be finished or canceled.
            }
            
        }

Send comments on this topic.