【发布时间】:2019-10-26 12:11:24
【问题描述】:
我已经把这个函数做成了一个JS文件...
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..
};
};
});
};
从 JSX 的 函数 得到 十六进制 颜色 value文件。
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;
};
在某种程度上它有效,但出于某种原因,我必须做同样的事情两次才能获得价值!!!知道为什么会这样吗?
感谢您的宝贵时间!!!
更新:更正,仅在第一次点击时有效。然后需要点击两次才能得到值!!!
【问题讨论】:
-
如何您是如何使用这些功能的?您提到了一个点击事件,但没有显示该代码。这似乎是问题的一个重要部分。
-
@Andy 喜欢这个
$("#current-color-pick-button").click(function(){getColors(true,true);});。当然来自 JS 文件。
标签: javascript photoshop photoshop-script