Ausgabe
Ich habe diese Funktion in eine JS -Datei gemacht …
function getColors(isPick, isForecolor)
{
var chosenFunction = 'getColor(' + isPick + ', ' + isForecolor + ')';
csInterface.evalScript(chosenFunction, function(result)
{
if(result !== 'undefined')
{
if (isForecolor == true){
foregroundHexColor = result;
// etc...
}
else
{
backgroundHexColor = result;
//etc..
};
};
});
};
die einen hexadezimalen Farbwert von dieser Funktion aus einer JSX -Datei erhalten.
function getColor(isPick, isForecolor)
{
var color_PickerCase;
var decimal_Color;
var hexadecimal_Color;
if (isForecolor == true)
{
color_PickerCase = app.foregroundColor.rgb.hexValue;
}
else
{
color_PickerCase = app.backgroundColor.rgb.hexValue;
};
if (isPick == true)
{
if (app.showColorPicker(isForecolor)){
decimal_Color = color_PickerCase;
hexadecimal_Color = decimal_Color.toString(16);
}
else
{
return;
};
}
else
{
decimal_Color = color_PickerCase;
hexadecimal_Color = decimal_Color.toString(16);
};
return hexadecimal_Color;
};
In gewisser Weise funktioniert es, aber aus irgendeinem Grund muss ich dasselbe zweimal tun, um den Wert zu erhalten !!! Irgendeine Idee, warum das passiert?
Vielen Dank für Ihre Zeit!!!
UPDATE : Eine Korrektur, es funktioniert nur beim ersten Klick. Dann muss zweimal geklickt werden, um den Wert zu erhalten !!!
Lösung
Nun, hier ist die Lösung …
function getColor(isPick, isForecolor)
{
var color_PickerCase;
var decimal_Color;
var hexadecimal_Color;
if (isPick === true && app.showColorPicker(isForecolor) === false)
{
return;
}
if (isForecolor === true)
{
color_PickerCase = app.foregroundColor.rgb.hexValue;
}
else
{
color_PickerCase = app.backgroundColor.rgb.hexValue;
}
decimal_Color = color_PickerCase;
hexadecimal_Color = decimal_Color.toString(16);
return hexadecimal_Color;
};
Wie joojaa von Grafikdesign sagte, habe ich nach der Farbe gefragt, bevor ich sie ausgewählt habe, und ich habe das letzte Mal die Farbform bekommen !!!
Beantwortet von – Simos Sigma
Antwort geprüft von – Pedro (FixError Volunteer)