Menu

Mouse Pointer

2009-02-26
2013-04-24
  • Cristian Matteucci

    Hello to all

    In thinwire can i change mouse pointer image when it passes on an object (textfield,label etc..)?

    Thank you!

     
    • Jordan Powell

      Jordan Powell - 2009-02-26

      As far I know, we have never implemented listeners for Mouse Over and such.  Has anyone out there added this in?  I would assume that this would make the application 'chatty'.

       
    • David R

      David R - 2009-03-06

      I have only a solution for Buttons. You can do it with Javascript import. reloadOnRefresh must be true.

      Java:

      WebApplication application = (WebApplication) Application.current();
              application.clientSideIncludeFile("mouseOver.js");
             
              Image press = new Image("blue.png");
              press.setPosition(0, 0);
              application.getFrame().getChildren().add(press);

              Image out = new Image("green.png");
              out.setPosition(0, 0);
              application.getFrame().getChildren().add(out);
             
              Image on = new Image("red.png");
              on.setPosition(0, 0);
              application.getFrame().getChildren().add(on);
             
              application.clientSideFunctionCall("addButton", on.getImage(),out.getImage(),press.getImage());

      Javascript(mouseOver.js):

      var imageArray  = new Array();
      var pressed        = 0;

      function addButton(on,out,down){
         
          imageArray[imageArray.length]= new Image();   
          imageArray[imageArray.length]= new Image();   
          imageArray[imageArray.length]= new Image();   
         
          on      = document.URL+"?_twr_="+on;
          out     = document.URL+"?_twr_="+out;
          down = document.URL+"?_twr_="+down;
         
          imageArray[imageArray.length-3].src = on;
          imageArray[imageArray.length-2].src = out;
          imageArray[imageArray.length-1].src = down;
      }

      function mover(e) {
          var i = 0;
          while (i< imageArray.length){
               if (e.target.src==imageArray[i].src){
                   e.target.src=imageArray[i+1].src;
                   if (pressed == 1){
                       e.target.src=imageArray[i+2].src;
                   }
                   else{
                       e.target.src=imageArray[i+1].src;
                   }
                   break;
                }
                i++;
          }
      }
      function mout(e) {
          var i = 0;
          while (i< (imageArray.length-1)){
               if (e.target.src==imageArray[i+1].src){
                   if (pressed == 0){
                       e.target.src=imageArray[i].src;
                   }
                   else{
                       e.target.src=imageArray[i-1].src;
                   }
                   break;
                }
                i++;
          }
      }

      function mdown(e) {
          pressed    = 1;
          var i     = 0;
          while (i< (imageArray.length-1)){
               if (e.target.src==imageArray[i].src){
                   e.target.src = imageArray[i+1].src;
                   break;
                }
                i++;
          }
      }

      function mup(e) {
          pressed    = 0;
          var i     = 0;
          while (i< (imageArray.length)){
               if (e.target.src==imageArray[i].src){
                    e.target.src =imageArray[i-1].src;
                    break;
                }
                i++;
          }
      }

      window.captureEvents(Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.MOUSEDOWN | Event.MOUSEUP)
      window.onmouseover = mover
      window.onmouseout = mout
      window.onmousedown = mdown
      window.onmouseup = mup

       

Log in to post a comment.