Loading ...
Sorry, an error occurred while loading the content.

Re: Colour picker and setValue

Expand Messages
  • Lucas Smith
    ... Mike, You re not missing anything obvious. This is a known bug with ColorPicker. You need to wrap the setValue in a setTimeout if it is called
    Message 1 of 5 , Nov 30, 2008
    • 0 Attachment
      --- In ydn-javascript@yahoogroups.com, "Mike Woods" <mike@...> wrote:
      >
      > Hi guys, I'm using the colour picker in an editor and i've found that
      > I can set the value of the colour picker however this isnt reflected
      > in the rgb fields which remain on pure white.
      >
      >
      > Event.onDOMReady(function() {
      > fgPicker = new YAHOO.widget.ColorPicker("foreground", {
      > showhsvcontrols: false,
      > showhexcontrols: true,
      > showwebsafe: false,
      > images: {
      > PICKER_THUMB: "assets/picker_thumb.png",
      > HUE_THUMB: "assets/hue_thumb.png"
      > }
      > });
      > fgPicker.setValue(['0','0','255'],true);
      >
      > Am I missing something painfully obvious here ?
      >


      Mike,

      You're not missing anything obvious. This is a known bug with
      ColorPicker. You need to wrap the setValue in a setTimeout if it is
      called immediately after construction:
      setTimeout(function () {
      fgPicker.setValue([0,0,255]);
      },10);

      Also, you *should* be able to just pass the initial color value to the
      'rgb' config ala
      ..,{
      showhsvcontrols: false,
      rgb: [0,0,255]
      ...
      });

      but this suffers from the same issue. This should be resolved in the
      next release.

      Incidentally, have a look at this example:
      http://yuiblog.com/sandbox/yui/v260/examples/colorpicker/colorpicker_two.html

      Hope this helps,
      Luke
    • bretlevy
      I *am* able to set the color value (yui 2.5.1) of the color picker. See: http://yuihelp.levycodev.com/demos/colorpicker/multi_colorpickers_on_a _page_help.php
      Message 2 of 5 , Dec 1, 2008
      • 0 Attachment
        I *am* able to set the color value (yui 2.5.1) of the color picker.
        See:

        http://yuihelp.levycodev.com/demos/colorpicker/multi_colorpickers_on_a
        _page_help.php

        I call setcolor after the object is created and/or shown, and I have
        not seen a problem...

        ~~bret


        --- In ydn-javascript@yahoogroups.com, "Mike Woods" <mike@...> wrote:
        >
        > Hi guys, I'm using the colour picker in an editor and i've found
        that
        > I can set the value of the colour picker however this isnt reflected
        > in the rgb fields which remain on pure white.
        >
        >
        > Event.onDOMReady(function() {
        > fgPicker = new YAHOO.widget.ColorPicker("foreground", {
        > showhsvcontrols: false,
        > showhexcontrols: true,
        > showwebsafe: false,
        > images: {
        >
        PICKER_THUMB: "assets/picker_thumb.png",
        >
        HUE_THUMB: "assets/hue_thumb.png"
        > }
        > });
        > fgPicker.setValue(['0','0','255'],true);
        >
        > Am I missing something painfully obvious here ?
        >
      • Lucas Smith
        ... [snip] Bret, There s a race condition that shows up occasionally whereby calling setValue(rgb) in thread will cause the RegionSlider to behave as though
        Message 3 of 5 , Dec 12, 2008
        • 0 Attachment
          --- In ydn-javascript@yahoogroups.com, "bretlevy" <bret@...> wrote:
          >
          >
          > I *am* able to set the color value (yui 2.5.1) of the color picker.
          > See:
          >
          > http://yuihelp.levycodev.com/demos/colorpicker/multi_colorpickers_on_a
          > _page_help.php
          >
          > I call setcolor after the object is created and/or shown, and I have
          > not seen a problem...
          >
          > ~~bret
          [snip]

          Bret,

          There's a race condition that shows up occasionally whereby calling
          setValue(rgb) in thread will cause the RegionSlider to behave as
          though the thumb's current y value is the top of draggable region. So
          if the thumb were initialized to #888, you couldn't drag the thumb
          above the halfway mark of the visible region, but you *could* drag the
          thumb below the visible bottom edge of the region. It wouldn't show
          up in your example because you are initializing the value to #ff0000,
          which places the thumb at the top of the region anyway.

          I don't suspect the bug will show up often (if ever) in the wild, but
          I have been able to consistently reproduce it in my tests.

          Regardless, the other failings of initialized value (setting rgb in
          the constructor config) warrant a bit of plumbing inspection for the
          next release.

          FYI,
          Luke
        Your message has been successfully submitted and would be delivered to recipients shortly.