2 Replies Latest reply on May 31, 2016 1:32 AM by Scorpio17523

    How do I create an Image/Picture button

    Scorpio17523 Level 1

      So I have a dialog window with 2 rows of panels. On each panel are standard buttons with text one them, however, I want one of these buttons, to instead had text, to show an image instead. How would I go about doing this?


      Below is my tester script creating a simple dialog window as described.

      The button I want to have an image is the one called CP which calls the colour wheel.


      I'm a complete beginner at scripting, so please keep that in mind with your explanations and examples, thanks.


      function hexToRGB(hex) {  
          var r = hex >> 16;  
          var g = hex >> 8 & 0xFF;  
          var b = hex & 0xFF;  
          return [r, g, b];  
      var win = new Window("dialog", "Picture Tester");  
      win.panel1 = win.add('panel', undefined);  
      win.panel1.group = win.panel1.add('group', undefined );  
      win.panel1.group.finalBtn = win.panel1.group.add('button',undefined, "Dummy", {name:'final'});  
      win.panel1.group.binderBtn = win.panel1.group.add('button',undefined, "Dummy", {name:'binder'});
      win.panel1.group.bocBtn = win.panel1.group.add('button',undefined, "Dummy", {name:'boc'});
      win.panel2 = win.add('panel', undefined);  
      win.panel2.group = win.panel2.add('group', undefined, );  
      win.panel2.group.closeBtn = win.panel2.group.add('button',undefined, "Close", {name:'close'});
      win.panel2.group.formatBtn = win.panel2.group.add('button',undefined, "Dummy", {name:'format'});
      win.panel2.group.colourPickBtn = win.panel2.group.add('button',undefined, "CP", {name:'colourPick'});
      //======================TEMP CLOSE BUTTON====================//
      //win.panel2.group.closeBtn = win.panel2.group.add('button',undefined, "Close", {name:'close'});
      win.location = [1850, 40];
      win.panel2.group.colourPickBtn.onClick = function(){  
          var g = win.graphics;  
          var color_decimal = $.colorPicker();  
          if (color_decimal>=0){  
              var color_hexadecimal = color_decimal.toString(16);  
              var color_rgb = hexToRGB(parseInt(color_hexadecimal, 16));  
              var color_that_ae_add_solid_understands = [color_rgb[0] / 255, color_rgb[1] / 255, color_rgb[2] / 255];      
              g.backgroundColor = g.newBrush(g.BrushType.SOLID_COLOR, color_that_ae_add_solid_understands);  
      //======================PALETTE WINDOW END===========================//
      //======================FORMAT FUNCTION END===========================//
      //===================TEMP CLOSE FUNCTION=====================//
      win.panel2.group.closeBtn.onClick = function(){  
      //===================TEMP CLOSE FUNCTION END=====================//
      win.show ();