2 Replies Latest reply on Jan 11, 2013 7:59 AM by Peter Kahrel

    ScriptUI rightClick menu

    Vamitul Level 4

      So, i have a listBox, and i  want to attach to it a context menu so i can delete items form it. However, there is no 'onRightClick' event. is there any way of fakeing it?

        • 1. Re: ScriptUI rightClick menu
          Vamitul Level 4

          this is annoying.. really really annoying...

          this is what i got so far.. close, but not close enough:

           

          function main(){
              var w=new Window('dialog','test',undefined);
              var  tst=w.add('listbox',undefined,['test1','test2','test3','test4']);
              tst.addEventListener ('mousedown', myFunction);
               function myFunction(e){
                  
                  if (e.button==2){
                      var menu=new Window('palette',undefined,undefined,{borderless:true});
                      menu.magins=[0,0,0,0];
                      menu.indent=0;
                      menu.frameLocation=[e.screenX,e.screenY];
                      var rem=menu.add('button',undefined,'Remove');
                      rem.onClick=function(){
                          //HOW TO REMOVE THE ITEM??? 
                          menu.close(1)};
                      //close menu on mouse out??, something like this:    
                      // menu.addEventListener ('mouseout', 'menu.close()'); //does not work properly
                      menu.show();
                                  }
                          
                  //alert('tt');
                  
                  }
              w.show();}main();
          
          
          • 2. Re: ScriptUI rightClick menu
            Peter Kahrel Adobe Community Professional & MVP

            dialog-type windows grab all focus, so you need to make your main window a palette as well:

             

            var w=new Window('palette','test')
            

             

            You then simply delete the selected list item:

             

            rem.onClick=function(){
                tst.remove(tst.selection);
                menu.close(1)};
                menu.show();
            }
            

            Peter