Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ColorPicker default palette

    Hi

    How can I change the default set of 40 colours (8x5) presented in the colorPicker ?

    Thanks, Ben.

    #2
    See ColorPicker.setColorArray()

    Comment


      #3
      I am using SGWTPro 4.1, there is no such method ColorPicker.setColorArray() or anything close to that ?

      Comment


        #4
        Ah, it's not exposed to SmartGWT, we'll take a look and update here when we have it fixed

        Comment


          #5
          Thanks, I will wait then ...

          It would be nice to have this defined globally (static method) not on a ColorPicker intance since most of the time ColorPicker is instanced by the framework not in the code.

          Thanks, Ben.

          Comment


            #6
            You can set global defaults for any Canvas - see setDefaultProperties() and setAutoChildProperties() - the autoChild in this case is called "colorArray", and it's an array of strings.

            Comment


              #7
              Sorry, ignore the AutoChild comment, colorArray isn't an autoChild - in this case, you'd just need to create a ColorPicker, call setColorArray() on it, and then pass it to ColorPicker.setDefaultProperties()

              Comment


                #8
                We've exposed ColorPicker.setColorArray() - please retest with a build dated October 12 or later.

                Comment


                  #9
                  This is in but only for a specific instance of ColorPicker, I expected a static method on ColorPicker that could be called at application startup to set colorArray for all future instances of ColorPicker.

                  I don't instantiate colorPicker myself, they are instantiated by sgwt framework from field declared of type="color".

                  Comment


                    #10
                    Hi Ben,

                    use ColorPicker.setDefaultProperties() in your onModuleLoad for this.

                    Best regards,
                    Blama

                    Comment


                      #11
                      Thank Isomorphic and Blama, it works very well.
                      For those who want to replace the not so nice default palette by another one better for graphics :

                      Code:
                      		ColorPicker colorPickerProperties = new ColorPicker();
                      		colorPickerProperties.setColorArray(new String[]{
                      				"#D8D8D8","#BBB6AE","#D6E0EC","#EFD3D2","#E6EED7","#DFD8E7","#D2EAF0","#FCE6D4",
                      				"#BFBFBF","#A29D96","#ADC1D9","#DFA7A6","#CEDDB0","#BFB2CF","#A5D5E2","#FACEAA",
                      				"#A5A5A5","#7D7974","#84A2C6","#CF7B79","#B5CC88","#9F8CB7","#78C0D4","#F7B580",
                      				"#8C8C8C","#575551","#456287","#903C39","#758C48","#604C78","#388194","#B77540",
                      				"#7F7F7F","#3E3C3A","#2E415A","#602826","#4E5D30","#403350","#255663","#7A4E2B"
                      		});
                      		ColorPicker.setDefaultProperties(colorPickerProperties);
                      Last edited by bda@celerity.be; 22 Oct 2014, 09:35.

                      Comment


                        #12
                        How can we change colorArray for ColorPickerItem?

                        Can you please tell me if the colors can be changed for ColorPickerItem as well? In add icon click handler if we getPicker it will not let me change it because the item was already draw.

                        Comment

                        Working...
                        X