3 Replies Latest reply on Jul 13, 2016 8:32 PM by Silly-V

    Method to dynamically change an image in scriptUI

      I'm trying to run before I can walk, but:

      Is there any way to respond to a click on an image in a dialog created with scriptUI?

      I want to modify which image is shown during the user's interaction with the dialog. I think that the "stack" method will create a stack of more than 32 layers, so it would be tidier to be able to just modify an instance of the image each time.

      I may also want to dynamically add more images during dialog, and therefore need to be able to resize the panel in the dialog window.


      
      
      var myIcons = new Array();
      myIcons[0] = "/path...to/image1.png";
      myIcons[1] = "/path...to/image2.png";
      var myPanel;
      myPanel = myCreatePanel();
      myPanel.show();
      myIncrement=1;
      for(var myCounter = 0; myCounter < 11; myCounter ++){
      $.sleep (100);
      }
      myPanel.hide();
      exit();

      function myCreatePanel(){
      myPanel = new Window('palette', 'test bed');
        with(myPanel){
         myPanel.myButton = add('image', undefined, myIcons[0]);
         myPanel.myButton.addEventListener('click', updateIcon);
        }
        return myPanel;
      }

      function updateIcon() {
      iconShow +=1; if (iconShow = 2){iconShow = 0};
      myPanel.myButton.image = myIcons[iconShow];
      }



      Any hints and help much appreciated...

      Thanks,
      Jezz