try replace you colorpicker() function with this one:
function colorpicker (result_color) {
var hexToRGB = function(hex) {
var r = hex >> 16;var g = hex >> 8 & 0xFF;var b = hex & 0xFF;
return [r, g, b]; };
var color_decimal = $.colorPicker();
if (color_decimal<0) return null; // added this line, to handle the case where the dialog is dismissed (else: errors)
var color_hexadecimal = color_decimal.toString(16);
var color_rgb = hexToRGB(parseInt(color_hexadecimal, 16));
var result_color = [color_rgb[0] / 255, color_rgb[1] / 255, color_rgb[2] / 255];
return result_color;
}
and the onClick callbacks for buttons by this:
function onButtonClick(){
var newcolor1 = colorpicker ();
if (newcolor1===null) return; // dialog dismissed
this.fillBrush = this.graphics.newBrush(this.graphics.BrushType.SOLID_COLOR, newcolor1);
// no need to call w.update()
// no need to reassign onDraw for the button, it's done already
// call onDraw for the button:
this.notify("onDraw");
}
colorbutton1.onClick = onButtonClick;
colorbutton2.onClick = onButtonClick;
It should work, but beware, there are a few bugs with ScriptUI and onDraw now (in CC2014 and later i think).
Xavier.