2 Replies Latest reply on Oct 24, 2013 9:02 AM by Sharath

    How to call different functions on mouse clicks

    Sharath

      I have created a transparent button of PageSize. When i click the button, i need to get the mouse co-ordinates and draw lines over that position and again if i click the mouse button have to draw lines over that position subsequently for 4 times.

      I have implemented the code as below:

       

      var aRect = this.getPageBox();

      var f = this.addField("myButton", "button", 0 , aRect);

      var i=0;

      if(i==0){

      f.setAction("MouseUp","cropll()");

      i++;

      }

      if(i==1){

      f.setAction("MouseUp","cropul()");

      i++;

      }

      if(i==2){

      f.setAction("MouseUp","cropur()");

      i++;

      }

      if(i==3){

      f.setAction("MouseUp","croplr()");

      i++;

      }

       

       

      function cropll(){

        var x = this.mouseX;

        var y = this.mouseY;

        // Draw lines

         ......

      }

       

      function cropul(){

        var x1 = this.mouseX;

        var y1 = this.mouseY;

        // Draw lines

      }

       

      function cropur(){

        var x2 = this.mouseX;

        var y2 = this.mouseY;

         //Draw lines

      }

       

      function croplr(){

        var x3 = this.mouseX;

        var y3 = this.mouseY;

      //Draw lines

      }

       

      Now when i run this code it calls only croplr() function and draw the lines.

       

      Can somebody please help me in restructuring the code such that ,

      On the first mouse click setAction method should call the function cropll(), on second click call cropul(), on third click cropur(), and on fourth croplr()