Copy link to clipboard
Copied
I see a lot of scripts that define their UI in a string and then add it to the panel, like this:
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "My Panel Name", [0, 0, 300, 300]);
res="group{orientation:'column', alignment:['fill', 'fill'], alignChildren:['fill', 'fill'],\
// Then a whole bunch of groups of tabs
}"
//Add resource string to panel
myPanel.grp = myPanel.add(res);
What benefit does this give you compared to defining each group / tab / etc as a variable and using standard scripting?
Copy link to clipboard
Copied
It's faster and more tidy to declare a resource string than to write out the code. That said there are limitations/bugs in the resource implementation though - for example the ListBox control doesn't recognize the listbox-specific elements like numberOfColumns and showHeaders when encoded in a resource strong vs doing it the normal way.
Copy link to clipboard
Copied
Horshack :
The 4th argument to add is an object (the creation properties), and must be declared as 'properties' (an object) in the ressouces as well:
var myList = myGroup.add("listbox", undefined, undefined, {numberOfColumns: 2, columnTitles: ["name", "value"], showHeaders: true});
"{/**/
myList: ListBox{properties:{numberOfColumns: 2, columnTitles: ['name', 'value'], showHeaders: true}},\
}";
alert(myGroup.myList.properties.numberOfColumns); // true
Xavier
Copy link to clipboard
Copied
Thanks for this. I had tried all combinations before, including without any enclosing brackets and also with "creation_properties" as the nested named bracket. Prior attempts would create the instance props within the LB but wouldn't actually be used by the LB logic. Did you find this by creating a LB the traditional way and inspecting the object? Because I couldn't find naming it "properties" in the documentation when I was first trying to troubleshoot it.
Copy link to clipboard
Copied
You can find infos on this in the Extend Script Tool Kit object model viewer (ScriptUI classes section), or the JavaScriptToolsGuide_[version].pdf
Every UI element has a 'properties' attribute, which remain 'undefined' until you actually set its value to some object.
You can put whatever you want in that object, but some specific property names will be recognized by ScriptUI and given special meanings (this depends on the element type, for instance 'readonly' is recognized for the type "edittext"; 'items', 'numberOfColumns',... for the type "dropdownlist", etc).
Xavier