Copy link to clipboard
Copied
there are actually three states a checkbox can be in: checked, unchecked, or indeterminate. but the value only show true or false

w = new Window ("dialog");
e = w.add ("checkbox", undefined, "test");
e.indeterminate = true;
w.show();
Copy link to clipboard
Copied
Hi,
Don't think you can achieve this through the native Checkbox. Only workaround I can't think of is using a pseudo checkbox of your own like an 3 state image. Youc could get inspired by Marc Autret's work on using sprites in ScriptUI :
http://www.indiscripts.com/post/2011/04/sprite-buttons-in-scriptui
You can cook something based on events to deal with sprite states
http://www.ozalto.com/en/event-driven-programming-with-extendscript/
HTH
Loic
www.ozalto.com
Copy link to clipboard
Copied
thanks I want to ask how to change the png graphic to code?
Copy link to clipboard
Copied

Below is my Script, when run and click 3 times, there will not show the image, can u fix it?
// Number of vertical sprites
// ---
var V_SPRITES = 3;
// InDesign CC Flag
// ---
const CC_FLAG = +(9 <= parseFloat(app.version));
// ScriptUI Image Offset Fixer in InDesign CS6 and earlier
// (This bug has been solved in CC i.e. ScriptUI 6.2.x)
// ---
const FIX_OFFSET = CC_FLAG ? 0 : 1;
// Force an Image widget to repaint (= onDraw trigger)
// CS4-CS6 -> just reassigning this.size
// CC -> we need to temporarily *change* the size
// Note: using layout.layout(1) would not work anymore in CC
// ---
Image.prototype.refresh = CC_FLAG ?
function()
{
var wh = this.size;
this.size = [1+wh[0],1+wh[1]];
this.size = [wh[0],wh[1]];
wh = null;
}:
function()
{
this.size = [this.size[0],this.size[1]];
};
var myCheckboxValue = File("C:/Users/dtp/Desktop/UI_Checkbox_Graphic/checkbox_value.png");
var w = new Window("dialog","ScriptUI Sprites (CS4/CS5/CS6/CC)");
w.alignChildren = "left";
var myTopGroup = w.add ("group");
myTopGroup.alignChildren = ["fill","fill"];
myTopGroup.orientation = "row";
iButton = myTopGroup.add("image", undefined, myCheckboxValue, {state:0}),
iSize = iButton.image.size,
spriteHeight = iSize[1] / V_SPRITES;
iButton.size = [iSize[0], spriteHeight];
myTextIndentText = myTopGroup.add("statictext", undefined, "Text Indent")
iButton.onDraw = function()
{
var dy = this.properties.state*spriteHeight + FIX_OFFSET;
this.graphics.drawImage(this.image,0,-dy);
};
var mouseEventHandler = function(ev)
{
//~ this.properties.state = ('mousedown'==ev.type)+2*('mousedown'==ev.type);
this.properties.state = ('mousedown'==ev.type)+this.properties.state*('mousedown'==ev.type);
this.refresh();
//~ if(this.properties.state ==2){
//~ this.properties.state =0;
//~ this.refresh();
//~ }
};
//~ iButton.addEventListener('mouseover', mouseEventHandler);
iButton.addEventListener('mousedown', mouseEventHandler);
//~ iButton.addEventListener('mouseup', mouseEventHandler);
//~ iButton.addEventListener('mouseout', mouseEventHandler);
w.show();
Copy link to clipboard
Copied
Hi,
if you comment out the useful parts, you can't expect it to work ![]()
if(this.properties.state ==3){
this.properties.state =0;
this.refresh();
Also you need to change 2 to 3
HTH
Loic
Copy link to clipboard
Copied
I do wonder how the Acrobat PDF Dialog in Illustrator has this done, this looks like a three-state as well. The dialog seems also ScriptUI. This is not with images, i see it also reacts to hover, active, and more states as well as colors.
The Image.prototype.refresh doesnt work anymore in CC2018. Keeps returning errors about the function not existing.
I can bypass it by assigning the image settings per event type, but it is not as nice as this solution
Copy link to clipboard
Copied
I don't think any native UI panel was ever designed with ScriptUI. Regarding ScriptUI inconsistencies over time, you may want to look at IDExtenso, a framework for scripters. It embarks a sublibrary for building UIs with ScriptUI while fixing many of its issues.
It also give access to three-state checkboxes:
Check implements a customizable checkbox that optionally supports three states and deals consistently with events. Can replace the native Checkbox widget.https://github.com/indiscripts/IdExtenso
HTH
Loic
Copy link to clipboard
Copied
Ow okay, so that is basically something like ScriptUI website made by Joonas?
Yeah i bumped into a thread yesyerday to make a custom 3 state checkbox. Issue is, illustrator doesnt seem to support Prototype, so we cant add a custom function to a base function.
Ill have a look at that IdExtenso. I see its for Indesign, yet i bet core features also work in other apps
EDIT
Seems i already had a look at this, January last year, totally forgot about that
Copy link to clipboard
Copied
You are right, IDExtenso is more focused on InDesign and I mentioned it as we are in the InDesign forum. However, I would give it a try regarding UI building. It may differ from Joonas' website as there are no WYSIWYG editors but you can probably go further.
You also have the opportunity to build a CEP panel that brings all the HTML capabilities but those panels may be overkill in some cases. It's up to you to evaluate the interest.
Copy link to clipboard
Copied
I'll stick with the website. I did years of editing in code editor and lots testing. That website is godsends:)
It's so easy to make a prototype now. I've adding quite of lot of interfaces now to scripts just so it makes them more dynamic and ease of use.
Thanks again for the heads-up about that InDesign helper
I do wonder what native dialogs are. They look and feel so simulat to the scriptui dialogs
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more