Context menus for your mods



  • Use this for your good mods.

    myElement.addEventListener("contextmenu",(event)=>myFunction(event));
    
    function myFunction(event){
     console.log(event);
     event.preventDefault();
       
     vivaldi.showMenu.create({ //function to create menu
    	mode:"context", //some other modes???
    	left:event.clientX,top:event.clientY, //mouse position or your own
    	items:[
    	 {name:"&New group...",id:1}, //& ==>underlined letter
    	 {name:"&Save current group",id:2},
    	 {name:"Save current tabs &as...",id:3},
             {name:"---",id:-1}, //separator
             {name:"Shortcut example",id:4,shortcut: "Ctrl+Y"}, //shortcut
             {name:"Checkbox example",type: "checkbox",checked:true,id:5}, //checkbox
             {name:"Children example",id:6,items:[ //parent menu
    	  {name:"Child 1",id:7} //submenu
    	 ]}
    	]},
    	function(e){ //menu closed
             console.log(e); //see console
             //{"alt":false,"center":false,"command":false,"ctrl":false,"id":-1,"left":false,"right":false,"shift":false}
    
    	 if(e.id==1){} //menu 1 clicked
    	 if(e.id==-1){} //no menu clicked (menu only closed)
    	}
     );
    
    }

Log in to reply
 

Looks like your connection to Vivaldi Forum was lost, please wait while we try to reconnect.