Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 取消选中复选框期间的环境函数-脚本CS6 64位Photoshop-错误_Javascript_Photoshop - Fatal编程技术网

Javascript 取消选中复选框期间的环境函数-脚本CS6 64位Photoshop-错误

Javascript 取消选中复选框期间的环境函数-脚本CS6 64位Photoshop-错误,javascript,photoshop,Javascript,Photoshop,我有功能,当您选中“相同高度和宽度变量约束”框时,当您将某个值传递到中时,“比例”将启用从高度grpHeight.numb到宽度grpWidth.numb的应对策略值,反之亦然。这分别在grpWidth.numb.onChange=函数和grpHeight.numb.onChange=函数中调用。 它是有效的。 此外,当您选中该复选框时,它将获取最高值并将其传递给第二个值。 如果constrainsProportions.value==true,则在条件中调用此函数 而且它也有效。 错误是当在任

我有功能,当您选中“相同高度和宽度变量约束”框时,当您将某个值传递到中时,“比例”将启用从高度grpHeight.numb到宽度grpWidth.numb的应对策略值,反之亦然。这分别在grpWidth.numb.onChange=函数和grpHeight.numb.onChange=函数中调用。 它是有效的。 此外,当您选中该复选框时,它将获取最高值并将其传递给第二个值。 如果constrainsProportions.value==true,则在条件中调用此函数 而且它也有效。 错误是当在任何编辑文本中传递值时,如果未点击“回车”或“退出编辑”,请单击复选框。它再次获取最高值并将其传递给第二个值。 它不应该起作用。任何值都不应更改。 即使第二次点击复选框时ConstraintsProportions.value为false。在这种情况下不应调用grpWidth.numb.onChange else grpHeight.numb.onChange 不确定错误在哪里

代码

提前感谢。

之所以会发生这种情况,是因为onChange事件是在控件失去焦点时发送的,而不是在您键入时发送的,因此代码会获得您在面板上看到的内容的早期版本。改用onchange:

#target photoshop

var mainWindow = new Window("dialog", "dynamic changing values");

var grpUnitVal = mainWindow.add("group")

var constrainsProportions = grpUnitVal.add("checkbox", undefined, "Same Height and Width");

//Edittext: Height
var grpHeight = mainWindow.add("group")
grpHeight.text = grpHeight.add("statictext", undefined, "Height: ");
grpHeight.numb =  grpHeight.add("edittext", undefined, 0);
grpHeight.numb.characters = 9;

//Edittext: Width
var grpWidth = mainWindow.add("group")
grpWidth.text = grpWidth.add("statictext", undefined, "Width:  ");
grpWidth.numb =  grpWidth.add("edittext", undefined, 0);
grpWidth.numb.characters = 9;

//Edittext: Width; if "constrains proportion" is checked, Heigth and Width values are changed in the same time
grpWidth.numb.onChange = function() {
    if (constrainsProportions.value == true){
        grpHeight.numb.text = grpWidth.numb.text;}
    }

//Edittext: Height; if "constrains proportion" is checked, Heigth and Width values are changed in the same time
grpHeight.numb.onChange = function() {
    if (constrainsProportions.value == true){
        grpWidth.numb.text = grpHeight.numb.text;}
    }

constrainsProportions.onClick = function() {

    //Set the same heighest value in Height and Width
    alert(constrainsProportions.value);
    if (constrainsProportions.value == true){
        if (parseInt(grpWidth.numb.text, 10) > parseInt(grpHeight.numb.text, 10)) {
             grpWidth.numb.onChange();} 
        else {
            grpHeight.numb.onChange();}
            }
}


mainWindow.show();
#target photoshop

var mainWindow = new Window("dialog", "dynamic changing values");

var grpUnitVal = mainWindow.add("group")

var constrainsProportions = grpUnitVal.add("checkbox", undefined, "Same Height and Width");

//Edittext: Height
var grpHeight = mainWindow.add("group")
grpHeight.text = grpHeight.add("statictext", undefined, "Height: ");
grpHeight.numb =  grpHeight.add("edittext", undefined, 0);
grpHeight.numb.characters = 9;

//Edittext: Width
var grpWidth = mainWindow.add("group")
grpWidth.text = grpWidth.add("statictext", undefined, "Width:  ");
grpWidth.numb =  grpWidth.add("edittext", undefined, 0);
grpWidth.numb.characters = 9;

//Edittext: Width; if "constrains proportion" is checked, Heigth and Width values are changed in the same time
grpWidth.numb.onChanging = function() {
    if (constrainsProportions.value){
        grpHeight.numb.text = this.text;}
    }

//Edittext: Height; if "constrains proportion" is checked, Heigth and Width values are changed in the same time
grpHeight.numb.onChanging = function() {
    if (constrainsProportions.value){
        grpWidth.numb.text = this.text;}
    }

constrainsProportions.onClick = function() {

    //Set the same heighest value in Height and Width
    // alert(constrainsProportions.value);
    if (this.value){
        if (parseInt(grpWidth.numb.text, 10) > parseInt(grpHeight.numb.text, 10)) {
             grpHeight.numb.text = grpWidth.numb.text;} 
        else {
            grpWidth.numb.text = grpHeight.numb.text;}
            }
}


mainWindow.show();