Copy link to clipboard
Copied
I am trying to put a function in a checkbox to execute a opentype feature.
This opentype feature isn't in Indesign UI but You can access using a script
I don't know what is wrong.
Please any help would be great:
/@targetengine "OpenTypeFeatures"
var palette = new Window("palette");
palette.text = "Character Variants";
palette.orientation = "column";
palette.alignChildren = ["center","top"];
palette.spacing = 30;
palette.margins = 60;
// GROUP1
// ======
var group1 = palette.add("group", undefined, {name: "group1"});
group1.orientation = "row";
group1.alignChildren = ["left","center"];
group1.spacing = 10;
group1.margins = 0;
group1.alignment = ["center","top"];
var checkbox1 = group1.add("checkbox", undefined, undefined, {name: "checkbox1"});
checkbox1.text = "CV01";
checkbox1.alignment = ["left","top"];
checkbox1.value = false
checkbox1.onClick = function () {
if (checkbox1.onClick() == true) {
checkbox1.value = true;
checkbox1.checked = true;
if( app.selection[0].hasOwnProperty("opentypeFeatures"))
app.selection[0].opentypeFeatures=[["cv01",1]];
}
else {
app.selection[0].opentypeFeatures = []; // reset to nothing
}
}
var convert_button1 = palette.add ("button", undefined, "OK");
convert_button1.onClick = function () { palette.close(0) }
palette.show();
Hi, Try below
#targetengine "session"
var palette = new Window("palette");
palette.text = "Character Variants";
palette.orientation = "column";
palette.alignChildren = ["center", "top"];
palette.spacing = 30;
palette.margins = 60;
// GROUP1
// ======
var group1 = palette.add("group", undefined, { name: "group1" });
group1.orientation = "row";
group1.alignChildren = ["left", "center"];
group1.spacing = 10;
group1.margins = 0;
group1.alignment = ["center", "top"];
var checkbox1 = group1.add("ch
...
Copy link to clipboard
Copied
Hi, Try below
#targetengine "session"
var palette = new Window("palette");
palette.text = "Character Variants";
palette.orientation = "column";
palette.alignChildren = ["center", "top"];
palette.spacing = 30;
palette.margins = 60;
// GROUP1
// ======
var group1 = palette.add("group", undefined, { name: "group1" });
group1.orientation = "row";
group1.alignChildren = ["left", "center"];
group1.spacing = 10;
group1.margins = 0;
group1.alignment = ["center", "top"];
var checkbox1 = group1.add("checkbox", undefined, undefined, { name: "checkbox1" });
checkbox1.text = "CV01";
checkbox1.alignment = ["left", "top"];
checkbox1.value = false
checkbox1.onClick = function () {
if (checkbox1.value == true) {
alert("Executed");
if (app.selection[0].hasOwnProperty("opentypeFeatures"))
app.selection[0].opentypeFeatures = [["cv01", 1]];
}
else {
app.selection[0].opentypeFeatures = []; // reset to nothing
}
}
var convert_button1 = palette.add("button", undefined, "OK");
convert_button1.onClick = function () { palette.close(0) }
palette.show();
The following statement is wrong
if (checkbox1.onClick() == true) {
instead of this you should check if value of checkbox is true then excute your code.
Copy link to clipboard
Copied
Thank You Charu, it works but I can't remove the opentype feature after checkbox is checked.
Could You help me one more time, please?
Best Regards
Sami
Copy link to clipboard
Copied
Please forget my last message.
It works perfectly!
Thank You very much!