问题
I’m able to get a reference to, for instance, the “Scripts” panel; but, although its constructor’s name is 'Panel'
, it doesn’t seem to have the show
and hide
methods like panels created through scripting, or the window
property, etc.:
var scriptsPanel = app.panels.item('$ID/Scripts')
scriptsPanel.window // → “Object does not support the property or method 'window'”
scriptsPanel.show(); // → “scriptsPanel.show is not a function”
It does have some of script-created Panels’ properties, though:
scriptsPanel.visible // → true or false
What are standard panels’ methods and properties, and where are they documented?
回答1:
There are several places where the DOM objects are documented, Adobe's official way would be to use the ExtendScript Toolkit to browse the objects and their methods and properties (in the ExtendScript Toolkit go to Help > Object Model Viewer).
Having said that, most ExtendScript users seem to find this browser cumbersome to use, so there are a few pages online that document the InDesign Object Model.
I personally use and prefer the InDesign ExtendScript API by Gregor Fellenz, but another popular one is Jongware's Adobe InDesign CS6 (8.0) Object Model JS viewer (that seems to be not updated anymore for more recent versions of InDesign). I prefer Gregor Fellenz' page, because it has a search function and I find it a bit easier to navigate.
The properties and methods of a panel in InDesign you could find here. Note that there is also the panel object of the ScriptUI, which is documented here. ScriptUI is Adobe's script language to create user interfaces. So the two panel objects have different methods and properties, that's why one of them didn't have the show()
method.
As you have noted, this leads to the somewhat confusing fact that there are two different types of objects with the same constructor name Panel
. However, there is no real ambiguity in the use of them, as the panels that are native to InDesign's UI are always children of the app
object, whereas the panels that you create in a script via ScriptUI are always children of other ScriptUI objects. The same goes for other DOM/ScriptUI name pairs, such as window
.
Note that the fact that there is a panel
object in InDesign means that there is also a panels
collection object, which has properties and methods to work with a collection of panels. This panels
object is documented here.
来源:https://stackoverflow.com/questions/58273369/what-methods-and-properties-are-provided-for-use-through-scripting-for-standard