Update the color sliders when eyedropper changes the value.

The hsv slider values are intentionally kept separate from the field
value so they are more stable when changed. They are initialized when
the editor is opened and only updated by the sliders. This was causing
the sliders not to update when a new color was chosen via eyedropper. To
get around this, manually update the internal hsv values when coming
back from the eyedropper callback so that the sliders get updated (which
happens in setValue).
This commit is contained in:
Paul Kaplan 2018-01-19 10:23:09 -05:00
parent 1afb6a2c67
commit 678aa9d805

View file

@ -256,6 +256,11 @@ Blockly.FieldColourSlider.prototype.sliderCallbackFactory_ = function(channel) {
Blockly.FieldColourSlider.prototype.activateEyedropperInternal_ = function() {
var thisField = this;
Blockly.FieldColourSlider.activateEyedropper_(function(value) {
// Update the internal hue/saturation/brightness values so sliders update.
var hsv = goog.color.hexToHsv(value);
thisField.hue_ = hsv[0];
thisField.saturation_ = hsv[1];
thisField.brightness_ = hsv[2];
thisField.setValue(value);
});
};