函数与 JS 和 JSX 文件之间的通信问题

Communication issue between functions into JS and JSX files

我已经把这个函数变成了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 文件。

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

在某种程度上它是有效的,但出于某种原因我必须做同样的事情两次才能获得价值!!!知道为什么会这样吗?

感谢您的宝贵时间!!!

UPDATE: 更正,仅在第一次点击时有效。然后需要点击两次才能得到值!!!

嗯,这是解决方案...

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

正如joojaa from graphicdesign所说,我是在挑颜色之前问的,我上次就拿到了颜色表!!!