【问题标题】:Communication issue between functions into JS and JSX files函数到 JS 和 JSX 文件之间的通信问题
【发布时间】: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


【解决方案1】:

好吧,这就是解决方案...

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;    
};

正如graphicdesignjoojaa所说,我是在挑选颜色之前询问颜色,而我最后一次得到颜色表!!!

【讨论】:

    猜你喜欢
    • 2019-09-11
    • 2017-04-08
    • 2016-05-04
    • 1970-01-01
    • 1970-01-01
    • 2021-02-02
    • 2015-03-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多